Alex Rivera | Logout

How is garbage collection done in Java and how does it compare to .net?

Asked 2010-05-28T04:00:53.420
10

I am wondering what the differences are or if it is the same across both.

Edit
Report

1 Answer

2

This question is not answerable.

Firstly, none of the relevant specifications will say anything about how Java or .net should implement garbage collection. So there is literally no "way that GC is done" in Java or in .net.

Secondly, the details of how GC is implemented differs between the various vendors for Java and .net respectively, and for any vendor the GC may change with each platform, each major version, minor version and even each patch version. On top of that, some implementations of Java allow you to choose between different garbage collectors using command line options.

Finally, it doesn't really matter how the GC is implemented in a Java or .net implementation provided that it can be made to work as required by the application. And for Java, the answer is that it can for most kinds of application. (The exceptions are typically systems/applications with hard real time requirements or very tight memory constraints.)

answered 2010-05-28T05:40:18.453

Your Answer