Dynamic Memory Allocation

Dynamic memory is memory that comes from the heap. The heap of the program starts off at an OS-defined default amount of space available for program consumption. As you allocate memory from the heap, it fills up, and then your program asks for more memory from the OS. Memory that you have released can be reused by your program. Memory allocated and subsequently freed is still charged to your program by the operating system. If you allocate 50 megabytes for temporary workspace and then free it all, your program will still have the 50 megabytes of memory allocated to it. This will eventually be swapped out to disk (on desktop systems) since you might not be using it. The total amount of memory can be considered a high ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.