简体   繁体   中英

Can a java application allocate more memory than specified by jvm startup parameters?

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?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM