3. Manual memory management
• Create an object:
– Declare an object name – creates a
pointer variable
– Use malloc() function, returns address of
newly allocated memory. Put that address
in the object pointer variable.
– When you’ve finished with the object, you
must explicitly destroy it using free()
4. Back to linked lists
Head
Graham Seb
Paul B /
NextFree
Tom
Sean
/
7. More on memory
• The Heap
– The memory locations available to application
programs for dynamic allocation.
• Dynamic allocation
– Memory is only allocated when required at run
time
• Memory leakage
– Memory is not released properly, eventually no
memory is left in the heap.