Reputation: 1333
Assuming a java application is not using any native libraries. Is there a way that it anyway can allocate more memory than specified by jvm startup parameters?
Asking the other way round: Can I rely that a java application will never allocate more memory than restricted by JVM startup parameters?
Upvotes: 2
Views: 2235
Reputation: 444
Indeed, you always need more memory than the -Xmx specified in your startup script. GC internals, JIT optimization tables, off heap allocations, permgen, thread stacks, etc are all taking their toll.
Upvotes: 2
Reputation: 2629
Yes, it can. It cannot allocate more memory on the JVM heap, but it can allocate native memory by using ByteBuffer.allocateDirect
or by calling to custom native code.
Upvotes: 2
Reputation: 152
No, a Java application can not go beyond the size specified by -Xmx
. It wouldn't make much sense if it could - why bother having -Xmx
in the first place, then?
I found an interesting link on Dream.In.Code where a user has given an example of a program that manages to resize itself, but it works by spawning a new JVM process.
Upvotes: -1