David
David

Reputation: 147

Has Java memory usage improved since JDK 6?

My organization is currently in the process of going through a system upgrade, moving up multiple versions. Our current version runs on Java 6, while the upgraded version will run on 8. We were given new hardware sizing documents which actually call for significantly less required memory than is being currently used (down to 16GB from 28GB). When we reached out to the vendor to indicate our concerns, they stated that there had been improvements in the application, as well as in the way that Java manages memory.

I'm willing to believe that there have been some improvements in application efficiency, but this seems like a dramatic change. Is it true that there have been significant improvements in Java memory management from v6 to v8?

Upvotes: 2

Views: 133

Answers (2)

Stephen C
Stephen C

Reputation: 719099

Is it true that there have been significant improvements in Java memory management from v6 to v8?

There have been changes in various aspects of Java that could affect the memory usage by an application. But whether they actually do affect the usage significantly will depend on the application ... and they way it was designed and coded, and the way it has been configured / deployed for your environment.

In my opinion1, what your vendor is saying is plausible, but it is not necessarily true. The only way to find out if it is true is to test the assertion that the (updated) application will work for you with a smaller memory footprint.

And the flipside is that you can't simply push back on the vendor; e.g. saying "StackOverflow doesn't believe you". They will counter with "where is the concrete evidence". And to get plausible evidence ... you need to test.

But here are the real questions:

  • If the vendor's assertions are over optimistic, what do you do then?
  • Is it your responsibility to fix it, or theirs? (What do the contracts say?)
  • Do you (or they) have a plan for that?
  • What happens if the plan fails?
  • Can you push back on the "new hardware sizing documents" (if you need to)?

1 - If course, that is just an opinion, and other opinions may differ. And that is the real problem here!

Upvotes: 0

Andreas
Andreas

Reputation: 159127

In Java 6, a String used a shared char[] with offset and count into the array, such that substring didn't have to copy the char[].

That was a premature optimization, and reality showed that many programs would load a big string, the create a few substrings and store those, cause the entire big string it stay in memory.

In Java 7, they eliminated the shared char[], improving memory use for many program. Some program might however use more memory. It depends on how strings are used. See e.g. "The substring() Method in JDK 6 and JDK 7".

It was still found that String objects was by far the single biggest consumer of memory in most programs, so that has been addressed:

These are all optimization on String only. There are likely other memory use improvements, but String is the biggest contributor in that area.

Upvotes: 4

Related Questions