C Tutorial Malloc() and Free() variants
The C Language
C History
Euclid’s Algorithm in C
Euclid on the PDP-11
Pieces of C
C Types
Struct bit-fields
Code generated by bit fields
C Unions
Layout of Records and Unions
C Storage Classes
malloc() and free()
Dynamic Storage Allocation
Simple Dynamic Storage Allocation
malloc() and free() variants

Fragmentation and Handles
Automatic Garbage Collection
Lazy Logical Operators
The Switch Statement
setjmp/longjmp: Sloppy exceptions
Nondeterminism in C




  • ANSI does not define implementation of malloc()/free(). Memory-intensive programs may use alternatives:

  • Memory pools: Differently-managed heap areas

  • Stack-based pool: only free whole pool at once

  • Nice for build-once data structures

  • Single-size-object pool:

  • Fit, allocation, etc. much faster

  • Good for object-oriented programs

On unix, implemented on top of sbrk() system call

(requests additional memory from OS).

Contact for more learning: webmaster@freehost7com