Yesterday i have just heard a lecture about garbage collection in java."Basics of Garbage Collection" on You Tube , so i was trying to implement my own garbage collection algorithm.So i just wanted to have any one implemented it.Is there a way to do it ? If yes can you please help me out with it. Thanks -Sagar S.
For implementing your own garbage collection, you also have to implement a complete Java VM, since they are quite woven into each other.
- For the garbage collector to have anything to do, it needs some Java objects.
- For the Java objects to be useful (and to be able to allocate them), you need to execute Java code.
So, if you want to implement this in Java, you would have to create a Java virtual machine based on Java.
Good luck :-)
If you only want to create a garbage collector for an existing VM, look at the open source ones like OpenJDK, GJC, Apache Harmony. I think they are modularized sufficiently so you could plug in another GC implementation there - you still have to make sure it fits to the memory allocation algorithm, and everything that accesses objects. You would have to implement this in the same language like the VMs themselves, I suppose (so mainly C or C++).
精彩评论