Skip to main content
Participant
September 30, 2020
Question

CF2016 on RHEL7 - java.lang.OutOfMemoryError: Compressed class space

  • September 30, 2020
  • 2 replies
  • 957 views

In our setup using JDK8 -  requests to different pages in CF application  returns this error:

(randomly occurs  any requests for the applciation - logon page of the application is also affected by this issue quite often )

java.lang.OutOfMemoryError: Compressed class space  - no stack trace available.

these pages coming back blank or failing for a period

JVM parameters are set with default settings - JVM settings related to compressed class or metaspace are NOT set .

CF reactor log viewer shows 30% of compressed class space is used at any time of the default 1G assigned.

JVM heap size is available on the system. It doesn't appear to be system related memory issue (top output)

similar issue reported with maxmetaspace here:

https://tracker.adobe.com/#/view/CF-4207269

 

any suggestion to track the cause or if there known bugs for Compressed class space?

 

TIA,

NS

 

 

This topic has been closed for replies.

2 replies

Charlie Arehart
Community Expert
Community Expert
September 30, 2020

Nalina, I want to add to what BKBK has, and focus first on a different point, which is what you are "seeing" in the graphs, and why it may seem confusing ("never above 30%"). Then I want to address the relationship between this space and the heap that you mention, and finally I have a proposal of yet another diagnostic step you may want to consider.

 

1) You observed that "CF reactor log viewer shows 30% of compressed class space is used at any time". I assume you mean instead to FusionReactor, and its logs (and "log viewer), which track each memory space (CF has no reactor log, and no logs tracking each memory space), and further that you are viewing the log in the FR "Archived Metrics" viewer, which is great.

 

2) But I want to share a warning about your observation that it (the "log viewer") "shows 30% of compressed class space is used at any time". Your (reasonable) conclusion seems to be that therefore, "the compressed class space never went above 30%, so how did it 'run out of memory'"? There are a couple of explanations for that, which are important to understand.

 

a) First, note that if you are indeed viewing the last log graphed before CF went down/you restarted it, there is a real possibility that CF could have become so unstable that it could not write its memory log files every 5 seconds (as it does, otherwise). In that case, you can't trust what you are seeing in the graphs, as I will explain.

 

So if you use the "view" menu on the top right of that page, and then look at the "spreadsheet" or "text" view, to see the real log lines, you may see that the time reflected in the log (in the first two cols on each line) is not only NOT every 5 seconds (before things started to go bad, compared to when "all was well"), but you may well see that it just STOPS logging entirely, perhaps minutes before you know that CF was brought down. That would confirm my suspicion, and would not be uncommon.

 

b) And both points can lead to the graph not being reliable. First, it may be missing datapoints (and the graphs may make inferences/smoothing that hides the gaps), and worse you may see the last point on the graph showing that 30%, but it could be from minutes before CF went down/you restarted it. To that last point, you can at least look at the times on the bottom of the graphs. You may notice that the intervals show 3/4 of the graph covering perhaps 30 mins, and the last 1/4 of the graph covering only 15 mins. That would be wrong, of course.

 

3) So with all that said, the OOM error you reported confirms that you DID run out of that memory space. And BKBK has pointed to the classic responses to consider. 

 

4) You mention that "JVM heap size is available on the system", by which I assume you mean that according to the FR graphs, the heap usage was not high. That may be so.

 

One thing to note is that the compressed class space does not come FROM (does not live WITHIN) the heap. It is separate.

 

I can say that with 100% certainty, because on a machine where I have only 800mb heap size (xmx), I can see in the FR graph of the compressedclassspace size that it's the 1000mb (1gb) that you both mention is the default if one does not change that size. (And let that be a lesson to those who look at the OS memory space, and wonder how CF's use of memory can be higher than the heap size. This space is one example, and the metaspace is another, and so on. Of course, it's one thing for such a memory space to have such a "max" value and for that space to be actually "used" or "allocated", and FR tracks that. The latter is what would contribute to memory space for the process in the OS.)

 

5) So bottom line, you do need to find out why you are using so much compressedclassspace.

 

6) BTW, you don't mention what version of FR you have. There's always the possibility that it (or some feature in it) is a contributor to this problem. The latest version is 8.5. What version are you on? And what CF version and update? and what JVM version?

 

7) Given that you are using FR, if the problem repeats often (frustrating as that is), you could try removing FR temporarily, to see if the problem went away. If it did, you would want to report this to the FR folks, who would jump on it.

 

And when I say remove it temporarily, I don't mean "uinstall it", or even remove it from CF using the FRAM Instance Manager (if you know what that means). Doing either would lose all the FR logs for the instance, which go back 30 days by default. Instead, I simply mean (carefully) comment out the two FR-related args in the CF jvm.config, and then restart CF. That will cause FR to be "removed" from CF, until you put those args back.

 

Let us know how things go.

/Charlie (troubleshooter, carehart. org)
Participant
September 30, 2020

Inspite of this OOM Compressed Class Space error, CF server process didn't stop, no restart was required to recover from this error quite conflicting  symptom. It seems to be self recovering from the situation and no other interruption to service noted other than those few pages (random) returning blank or error to few users which seems this error in the CF logs  is red herring. From server end no manual action was needed to correct it when user reports the problem. Is that normal in CF for this scenario?

Thanks for detailed responses. I will review these to my setup.

Charlie Arehart
Community Expert
Community Expert
September 30, 2020

Ah, sorry for my mistakenly assuming it led to an outage/restart. I see now you did say it was just a few pages. I just didn't get that CF stayed up. I understand now.

 

So there are two ways to look at this.

 

Personally, I would (like BKBK) question when such a large memory space is used up unexpectedly. To your last question, no, this is not a "normal" error. I very (very) rarely see it--and all I do all day is troubleshoot CF servers for folks, whether on a consulting basis or here, so it really is not "normal". 🙂

 

But if you DO have ample available memory on the machine (not in the heap), then you could certainly raised the size of the compressedclassspace. In some situations, that can seem more expedient than troubleshooting things. If it works, great. Sometimes, a given space only needs to be a little bigger to never complain again. 

 

And you have FR which you can use to watch the space, to see how things go. And I'll add that FR Cloud (the part of FR that runs in the cloud, using data from your on-premise CF and FR) not only has alerts like the on-premise FR version does, but it has FAR more things it can "check", including the compressedclassspace use. 🙂 So you could even know in advance if it started rising toward your new limit.

 

All that said, I'd still think it useful to understand if the FR logs you DO have showed whether the space WAS rising high enough to cause that error. It would seem they should, unless there was one of the problems I described. Then again, the FR Cloud alerts would also be watching these things every 5 seconds, and could see it when you may not--or can be told to alert you when FR Cloud is perhaps getting NO data from CF.

 

Hope that helps.

/Charlie (troubleshooter, carehart. org)
BKBK
Community Expert
Community Expert
September 30, 2020

The root cause is clear. The space that your application needs for UseCompressedClassPointers exceeds the available CompressedClassSpaceSize. The default value for the size is 1GB. 


If you're certain that your application doesn't use that many files, then the error suggests that something else in your application is creating a lot of classes and never releasing them. Think of a classloader, for example.

 

This StackOverflow post on compressed class space contains the following helpful suggestions:

 

  1. If your application can manage without so many files, then disabling compressed class pointers is perhaps an option. The relevant JVM flag is -XX:-UseCompressedClassPointers
  2. If your application does indeed need that many files, then you could consider increasing CompressedClassSpaceSize to 2GB. The relevant flag is -XX:CompressedClassSpaceSize=2g.
  3. In any case, you should enable the following JVM settings to troubleshoot the classes loaded:
    -XX:+PrintGCDetails -XX:+TraceClassUnloading -XX:+TraceClassLoading
Participant
October 8, 2020

Thanks for the pointers shared so instantly on the issue I reported. greatly helpful BKBK as well Charlie_Arehart great learning from the information shared.

As a temporary relief CF instance is set to restart periodically as it is found helpful to stop Compressed class space error. Restart of CF instance leaves more free memory on the system.