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
How can we set max limit on off heap usage in azul prime jvm
189 Views Asked by Nishant Modi AtThere are 2 best solutions below

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.
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.