Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C dynamic memory allocation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Dynamic memory management in the C programming language}} {{Redirect|Malloc|Mallock|Mallock}} {{Use dmy dates|date=May 2021|cs1-dates=y}} {{C Standard Library}} '''C dynamic memory allocation''' refers to performing [[manual memory management]] for [[dynamic memory allocation]] in the [[C (programming language)|C programming language]] via a group of functions in the [[C standard library]], namely {{mono|malloc}}, {{mono|realloc}}, {{mono|calloc}}, {{mono|aligned_alloc}} and {{mono|free}}.<ref name="c99">{{cite tech report |title=7.20.3 Memory management functions |work=ISO/IEC 9899:1999 specification |page=313 |url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf }}</ref><ref>{{cite web |last=Summit |first=Steve |title=Chapter 11: Memory Allocation |work=C Programming Notes |url=http://www.eskimo.com/~scs/cclass/notes/sx11.html |access-date=11 July 2020}}</ref><ref>{{cite web|url=https://linux.die.net/man/3/aligned_alloc|title=aligned_alloc(3) - Linux man page}}</ref> The [[C++]] programming language includes these functions; however, the operators [[new and delete (C++)|{{mono|new}} and {{mono|delete}}]] provide similar functionality and are recommended by that language's authors.<ref>{{cite book |last=Stroustrup |first=Bjarne |author-link=Bjarne Stroustrup |year=2008 |title=Programming: Principles and Practice Using C++ |publisher=Addison Wesley |isbn=978-0-321-54372-1 |page=1009}}</ref> Still, there are several situations in which using <code>new</code>/<code>delete</code> is not applicable, such as garbage collection code or performance-sensitive code, and a combination of <code>malloc</code> and placement <code>new</code> may be required instead of the higher-level <code>new</code> operator. Many different implementations of the actual memory allocation mechanism, used by {{mono|malloc}}, are available. Their performance varies in both execution time and required memory.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)