Reputation: 9532
We have recently upgraded one of our applications from Java 1.4 to Java 6.
With some load & performance tests, we observed that available memory stayed in general at much lower levels in Java 6 than at what it used to be with Java 1.4.
After some profiling on the app with Java 6, we noticed that many objects no longer referenced by any other objects (i.e. candidates for garbage collection) stayed in memory and were apparently never garbage collected. We took that as the explanation for the lower available memory.
Question is: did the way garbage collection behaves changed from Java 1.4 to Java 6?
Upvotes: 6
Views: 2753
Reputation: 20124
There have been several optimizations on garbage collecting between 1.4 and 5 and between 5 and 6.
Oracle/Sun have some whitepapers on the performance differences online:
Java 5 Performance White Paper
Java 6 Performance White Paper
Upvotes: 5
Reputation: 93157
Java SE changed a lot in 8 years.
Concerning the garbage collector, it has been improved a lot with Java SE 6. In Java SE 6 Update 14 the new Garbage First GC was introduced.
Upvotes: 3
Reputation: 308001
did the way garbage collection behaves changed from Java 1.4 to Java 6?
Definitely!
Java 1.4 to Java 6 is a pretty long timespan (almost 5 years between the initial releases and more than 8 years between the initial 1.4 release and the current Java 6 release, according to this wiki article).
Many changes and optimizations are applied in that time and you should not really care as long as your program still works.
Having more used memory only means that the JVM doesn't waste time with garbage collection when it doesn't need to. If you want it to use less memory, then you should reduce the maximum heap (or otherwise tweak the JVM parameters; this article explains how to do that in Java 5, much of the advice is still applicable).
It's somewhat different if you actually get OutOfMemoryError
that you didn't get previously. Then you should check how you use weak and soft references or as a last resort try to find out if you hit a JVM bug.
Upvotes: 15