Docsity

Garbage Collector vs Explicit Allocation - Operating Systems | CMPSCI 377, Study notes of Operating Systems

Toggle sidebar
bg1
CMPSCI 377 Operating Systems Spring 2007
Lecture 5: October 2
Lecturer: Emery Berger Scribes: Diack Ba, Chris Galardi
5.1 Garbage Collector vs. Explicit Allocation (Malloc/Free)
•BDW Collector: Resolve function name with definition (malloc,free) then call malloc to go to the
address.
•command line for the garbage collector - ”‘g++ myprog.cpp -lgc”’
•The programmer has to tell gcc where to find the garbage collector when installed : export LD PRELOAD:
/path/to/lgc.so (use colons for delims)
5.1.1 BWM Collector
•’snap in’, conservative collector for cpp.
•can be told not to ignore free() as most cpp collectors do, which allows you to explicitly manage
memory and also be cleaned up after.
5.2 Oracular Memory Manager
•We cannot insert frees in Java. (directly control the gc)
•Note that you cannot extend the LEA (java gc) allocator either
•So we run JVM inside a simulator, where the program is run once to gather information then run again
after we understand its memory usage habits
•After a program has been run once, the ’oracles’ already know how it’s going to use memory at any
point in the future (hopefully)
•with this information, the simulator can free memory because the oracles know that an object is dead
after a certain point.
5.2.1 Object lifetime and Oracle Placement
5.2.2 Liveness Oracle Generation
•we first create an object wich will first live. We CANNOT free it.
•a variable is dead then it’s never going to be used again.but we don’t know in advance
•The earliest we can free an object is when it dies, the latest is when it become unreachable
5-1
pf2

Partial preview of the text

Download Garbage Collector vs Explicit Allocation - Operating Systems | CMPSCI 377 and more Study notes Operating Systems in PDF only on Docsity!

CMPSCI 377 Operating Systems Spring 2007

Lecture 5: October 2

Lecturer: Emery Berger Scribes: Diack Ba, Chris Galardi

5.1 Garbage Collector vs. Explicit Allocation (Malloc/Free)

  • BDW Collector: Resolve function name with definition (malloc,free) then call malloc to go to the address.
  • command line for the garbage collector - ”‘g++ myprog.cpp -lgc”’
  • The programmer has to tell gcc where to find the garbage collector when installed : export LD PRELOAD: /path/to/lgc.so (use colons for delims)

5.1.1 BWM Collector

  • ’snap in’, conservative collector for cpp.
  • can be told not to ignore free() as most cpp collectors do, which allows you to explicitly manage memory and also be cleaned up after.

5.2 Oracular Memory Manager

  • We cannot insert frees in Java. (directly control the gc)
  • Note that you cannot extend the LEA (java gc) allocator either
  • So we run JVM inside a simulator, where the program is run once to gather information then run again after we understand its memory usage habits
  • After a program has been run once, the ’oracles’ already know how it’s going to use memory at any point in the future (hopefully)
  • with this information, the simulator can free memory because the oracles know that an object is dead after a certain point.

5.2.1 Object lifetime and Oracle Placement

5.2.2 Liveness Oracle Generation

  • we first create an object wich will first live. We CANNOT free it.
  • a variable is dead then it’s never going to be used again.but we don’t know in advance
  • The earliest we can free an object is when it dies, the latest is when it become unreachable

5-2 Lecture 5: October 2

  • rechability-based: most conservative (could result in memory leak).
  • lifetime-based: most aggressive (could result in crash)

5.2.3 Conclusion

  • GC uses much more memory to achieve the same speed as explicit allocation