0

We are using azul prime, and it is using a lot of off heap memory. is there any way to give limit for off heap memory like we give for heap

Nishant Modi
  • 669
  • 1
  • 6
  • 19

2 Answers2

0

There is a standard JVM flag that can be used to control this, -XX:MaxDirectMemorySize. I checked the Prime JVM, and the default setting for this is zero, which is the same as for OpenJDK HotSpot. Zero means there is no limit.

However, I think you need to be careful changing this because this space is not like the heap (obviously). If you limit the heap size, your application can still (potentially) continue to work by running the garbage collector more frequently. Off-heap memory is not collected automatically; if you make the value smaller than is required, you'll cause an abrupt halt of your application.

I would recommend investigating why the off-heap memory usage is high. This is probably a result of what your application is doing rather than the Prime JVM's usage.

The one thing I can think of that might cause this outside the application is the cache for JIT-compiled code. You can see how much this is by adding the –XX:+PrintCodeCache flag. I think that is unlikely to be an issue since this will typically be of the order of MB, not GB.

Speakjava
  • 3,177
  • 13
  • 15
  • The one thing which is different on impacted environment is that, we are doing heavy groovy processing, millions of groovy scripts are getting executed in a day – Nishant Modi Apr 19 '23 at 06:55
  • Have you tried running this on the HotSpot JVM (i.e. a build of OpenJDK like Zulu)? That would show whether the issue is because of the way the Prime JVM works as opposed to the application. – Speakjava Apr 19 '23 at 13:48
0

Although we couldn't found a way to restrict the off heap usage , but the issue was with Azul's default compiler falcon and its way to handle Dynamic Code generation. After switching on KestralC2 on such environment where dynamic code generation is huge we have solved the issue of off heap mem going beyond control.

Nishant Modi
  • 669
  • 1
  • 6
  • 19