Changing garbage collection from Java 1.4 to Java 6?

We recently upgraded one of our applications from Java 1.4 to Java 6.

With some load and performance tests, we noticed that the available memory remained generally at much lower levels in Java 6 than what was before with Java 1.4.

After some profiling of the application with Java 6, we noticed that many objects that no longer reference any other objects (for example, candidates for garbage collection) remained in memory and, apparently, were never collected by garbage. We took this as an explanation for the lower available memory.

Question: did the garbage collection behavior change from Java 1.4 to Java 6?

+6
java garbage-collection
source share
3 answers

has garbage collection behavior changed from Java 1.4 to Java 6?

Of course!

Java 1.4 to Java 6 is a fairly long period of time (almost 5 years between the initial releases and more than 8 years between the initial 1.4 release and the current version of Java 6 , according to this wiki article ).

At this time, many changes and optimizations are applied, and you still do not need while your program is still running.

Having more memory used means that the JVM does not waste time collecting garbage when it is not needed. If you want it to use less memory, then you should reduce the maximum heap (or otherwise configure the JVM parameters; this article explains how to do this, that in Java 5 most of the recommendations are still applicable).

This is slightly different if you really get an OutOfMemoryError that you haven't received before. Then you should check how you use weak and soft links or, as a last resort, try to find out if you are in the JVM error.

+15
source share

There were several optimizations for garbagecollecting between 1.4 and 5 and between 5 and 6

oracle / sun has some online performance recommendations.

http://java.sun.com/performance/reference/whitepapers/5.0_performance.html#2.11

http://java.sun.com/performance/reference/whitepapers/6_performance.html#2.2

+5
source share

Java SE has changed a lot over 8 years.

As for the garbage collector, it has improved significantly with Java SE 6 . Java SE 6 Update 14 introduced the new Garbage First GC.

+3
source share

All Articles