Pointers and memory

233 views
192 views

Published on

How memory is managed

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
233
On SlideShare
0
From Embeds
0
Number of Embeds
101
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Pointers and memory

  1. 1. Pointers and Memory
  2. 2. Garbage Collectors• Yes • No (usually) – Python – C – Visual Basic – C++ – Java – Pascal – C#
  3. 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. 4. Back to linked listsHead Graham Seb Paul B /NextFree Tom Sean /
  5. 5. Delete GrahamHead Graham Seb Paul B /NextFree Tom Sean /
  6. 6. 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.

×