Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I experiment with garbage collection?

I'm interested in how garbage collection works. I've read up on how some work such as mark-and-sweep, stop-and-copy, generational GC, etc... I'd like to experiment with implementing some of these and comparing their behaviors. What's a good way to get started experimenting with my own? Ideally something in C, Java or Python (although the last two are themselves garbage-collected so it seems it'd be hard to use them...)

like image 411
Claudiu Avatar asked Oct 29 '08 19:10

Claudiu


People also ask

Which method is used for garbage collection?

The gc() method is used to invoke the garbage collector to perform cleanup processing. The gc() is found in System and Runtime classes.

How do you explain garbage collection?

Garbage collection (GC) is a memory recovery feature built into programming languages such as C# and Java. A GC-enabled programming language includes one or more garbage collectors (GC engines) that automatically free up memory space that has been allocated to objects no longer needed by the program.

What is garbage collection in performance testing?

Garbage collection is the memory management process for objects in the heap. As objects are allocated to the heap, they run through a few collection phases – usually rather quickly as the majority of objects in the heap have short lifespans.


2 Answers

Never played with it myself, but the one that always gets mentioned for use with C/C++ is Hans Boehm's.

like image 61
Michael Burr Avatar answered Oct 03 '22 20:10

Michael Burr


the .NET runtime and Java runtime are now open source, so you can experiment with the runtime it self if you want to play around with a current support programming language. However if you wanted to do this yourself you would probably have to create your own runtime which has it's own language.

like image 22
Nick Berardi Avatar answered Oct 03 '22 22:10

Nick Berardi