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

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

Info icon This 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
Image of page 1

Info icon This 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
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
Image of page 3

Info icon This 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
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
Image of page 5

Info icon This 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
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
Image of page 7

Info icon This 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.
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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern