Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage collection implementation

In which language garbage collection algorithm is implemented for java.i think c, please confirm?

like image 827
Suresh S Avatar asked Jun 01 '10 07:06

Suresh S


People also ask

How are garbage collectors implemented?

The simplest way to implement a garbage collector is: Make sure you can collate the global roots. These are the local and global variables that contain references into the heap. For local variables, push them on to a shadow stack for the duration of their scope.

What is garbage collection process?

A garbage collection has the following phases: A marking phase that finds and creates a list of all live objects. A relocating phase that updates the references to the objects that will be compacted. A compacting phase that reclaims the space occupied by the dead objects and compacts the surviving objects.

What is the purpose of garbage collection?

Garbage collection (GC) is a dynamic approach to automatic memory management and heap allocation that processes and identifies dead memory blocks and reallocates storage for reuse. The primary purpose of garbage collection is to reduce memory leaks.


1 Answers

It depends on the JVM. Often, the garbage collector is implemented in the same language as the JVM, but that is not always the case.

In Maxine, both the JVM and the garbage collector are implemented in Java.

In Jikes, both the JVM and the garbage collector are implemented in Java.

In Rava, the JVM is implemented in Ruby and the garbage collector isn't implemented at all: Ruby already is a memory-managed language, there is no need to implement a separate garbage collector.

In IKVM, the JVM is implemented in C# and CIL and the garbage collector isn't implemented at all: the CLI VES already is a memory-managed environment, there is no need to implement a separate garbage collector.

In VisualAge for Java, the Java bytecode gets translated to Smalltalk bytecode and then executed by the Smalltalk environment. Smalltalk already is a memory-managed language, there is no need to implement a separate garbage collector.

In VMKit, both the VM and the garbage collector are written in C++.

In HotSpot, both the JVM and all 4 (or however many there currently are) garbage collectors are written in C++.

like image 148
Jörg W Mittag Avatar answered Oct 19 '22 20:10

Jörg W Mittag