Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have started learning about C# and I come to what is called 'Automatic memory management' or 'Garbage collectors' and I'm wondering if Java contains something like this as well? and if it does, does it do that as effective as C# when it comes to windows desktop application and web applications?

share|improve this question

Java is a garbage collected language though the collection model is different than C#'s. Effectiveness would vary considerably depending on the structure of the program but Java does run just fine on Windows and the Web.

share|improve this answer
Also, the actual GC strategy (and the way memory is organized) used by the JVM can be adjusted with startup parameters. See – Hanno Fietz Nov 15 '11 at 10:30

Yes, the algorithm used by the Microsoft's 'Common Language Runtime' is known as the Mark-Compact Algorithm. I also read that the Java Runtime uses this as well. Also, if you run into any other C# vs Java sort of comparison like questions, this document may be of interest. A Comparison of Microsoft's C# Programming Language To Sun Microsystems' Java Programming Language, By Dare Obasanjo.

share|improve this answer

Yes, Java does have garbage collection and "effective" is a relative term hard to judge without some more specific criteria.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.