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!
==Allocation size limits== The largest possible memory block <code>malloc</code> can allocate depends on the host system, particularly the size of physical memory and the operating system implementation. Theoretically, the largest number should be the maximum value that can be held in a <code>[[size_t]]</code> type, which is an implementation-dependent unsigned integer representing the size of an area of memory. In the [[C99]] standard and later, it is available as the <code>SIZE_MAX</code> constant from <code><[[stdint.h]]></code>. Although not guaranteed by {{nowrap|ISO C}}, it is usually <code>2^(CHAR_BIT * [[sizeof]](size_t)) - 1</code>. On glibc systems, the largest possible memory block <code>malloc</code> can allocate is only half this size, namely <code>2^(CHAR_BIT * [[sizeof]](ptrdiff_t) - 1) - 1</code>.<ref>{{cite web |url=https://sourceware.org/bugzilla/show_bug.cgi?id=23741#c2 |title=malloc: make malloc fail with requests larger than PTRDIFF_MAX |date=18 April 2019 |website=Sourceware Bugzilla |access-date=30 July 2020}}</ref>
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)