robjwilkins
robjwilkins

Reputation: 5672

Java Compressed Class Space behaviour

Similar question to this: java.lang.OutOfMemoryError: Compressed class space however my application is not exiting with an OutOfMemory error, and I'm interested in the expected usage of JVM compressed class space.

Should my application compressed class space go up and down with garbage collection? If I see a gradual increase in compressed class space usage over time does this indicate a memory leak (Survivour and Eden space go up and down with garbage collection and don't appear high)?

We had an issue where compressed class space hit a 1Gb limit and the application became unresponsive. I have made a number of changes to attempt to address this but struggling to tell 100% if the problem is fixed. If I were to run short of compressed class space is it reasonable to just increase it, or will my app potentially continue to all available until it runs out? If Eden and Survivor space are going up and down alongside garbage collection does this mean my app does not have a memory leak, or could a compressed class space problem still exist?

Upvotes: 0

Views: 83

Answers (1)

Stephen C
Stephen C

Reputation: 719641

Should my application compressed class space go up and down with garbage collection?

Compressed class space usage will go up when new classes are defined, and will go down if the garbage collector detects that existing classes are no longer reachable ... and collects them.

We can't say what should happen for your application, because it depends on how it is designed to work. If your application is defining new classes dynamically AND you have fixed any class leaks (i.e. memory leaks of classes) THEN you should see that compressed class space go up AND down with garbage collection.

If I see a gradual increase in compressed class space usage over time does this indicate a memory leak?

Probably yes.

If I were to run short of compressed class space is it reasonable to just increase it, or will my app potentially continue to all available until it runs out?

If the increase rate is roughly linear, eventually you will get to a point where you can no longer increase the compressed class space limit.

But we can't tell you how your application behaves. And hence, whether it is reasonable to a (just) increase the limit. It will depend on what the actual rate of increase is, whether it is linear, what are the real world consequences of running out, and so on. And also ...

  1. how hard it would be to find the cause of the class leak, and
  2. how hard it would be to fix it.

If Eden and Survivor space are going up and down alongside garbage collection does this mean my app does not have a memory leak, or could a compressed class space problem still exist?

The latter.

Upvotes: 1

Related Questions