{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec31-32-digraph-trav-apps TODO.pdf

lec31-32-digraph-trav-apps TODO.pdf - CS F211 Data...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS F211 Data Structures & Algorithms G RAPH A LGORITHMS Directed Graphs - Traversal Application Garbage Collection Aside: Memory Allocation Data Structures Directed Acyclic Graphs Topological Sorting 1 4/29/2017 Sundar B. CSIS, BITS, Pilani
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A PPLICATION : G ARBAGE C OLLECTION 4/29/2017 2 Sundar B. CSIS, BITS, Pilani
Background image of page 2
P ROCESS S PACE Process Space: A program under execution is a process. Each process uses its own exclusive “virtual address space” e.g. in a 32-bit system the addresses range from 0000 0000 to FFFF FFFF (hex) This is irrespective of the physical memory size and availability. The virtual address space is laid out in different parts: Code area Data area Q: Why are they separate? 4/29/2017 3 Sundar B. CSIS, BITS, Pilani
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P ROCESS S PACE R UN T IME M EMORY A LLOCATION 4/29/2017 Sundar B. CSIS, BITS, Pilani 4 Different Data areas: Global / Static area: allocated once data objects live until end of execution Stack area : a frame allocated on each call and deallocated on return Heap area : allocated dynamically explicit i.e. programmer specified e.g. malloc in C / C++ or new in C++ / Java implicit in languages where all data objects are dynamically allocated
Background image of page 4
P ROCESS S PACE R UN T IME M EMORY A LLOCATION [2] 4/29/2017 Sundar B. CSIS, BITS, Pilani 5 Different Data areas: Global / Static area: Stack area: Heap area: A A A A A A F A F F F A Frame 0 Frame 1 Static Area Heap Stack push on call pop on return
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P ROCESS S PACE R UN T IME M EMORY D E -A LLOCATION Deallocation of heap-allocated objects: Explicitly by programmer (free in C/C++, delete in C++) Implicitly by runtime system/environment Garbage Collectors (e.g. Java) What is Garbage? Any (heap) allocated but unused (i.e. inaccessible) data object is garbage . 4/29/2017 6 Sundar B. CSIS, BITS, Pilani
Background image of page 6
W HAT IS G ARBAGE ? When does an object become unused (or inaccessible )? When it goes out of scope (implicitly allocated) When pointers pointing to it (referring to it) go out of scope Conversely, which data objects are accessible ? Any heap allocated object is accessible if it can be accessed through a sequence of pointer de- references starting from another object in scope (i.e. another accessible object) Objects in Global and Stack areas are - by definition - accessible 4/29/2017 7 Sundar B. CSIS, BITS, Pilani
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
D I G RAPHS A PPLICATION G ARBAGE C OLLECTION Garbage Collection Problem 2 logical phases: 1. Garbage Identification : Identify all heap allocated objects that are not accessible 2.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}