Higher memory consumption in Java 8 than Java 7

2019-03-30 12:46发布

问题:

I'm developing a JavaFX desktop application using Java 7. The application I'm developing uses 10-12 background threads which gets system information or makes HTTP request. I also use some JNA and JNI code.

When i limit the heap size to 40 MB, it's fairly enough and the application runs without a problem with total ~100 MB memory.

However since Oracle is dropping support for Java 7 in April, I decided to upgrade the application to Java 8, the upgrade went smoothly, not much code change required, but i noticed the total memory consumption increased to 130+-20 MB. I researched about this problem, and found out Java 8 introduced Metaspace, I think that may be the problem, but in Java 7 I never set the PermGenSize so in the end I have no idea why the application uses more memory.

Just so you know Metaspace usage is about 33-36 MB in VisualVM.

Any help would be appreciated , thanks

-------SOLVED---------

The problem was; the JDK I was using was 64 bit, since 64 bit JDK on Windows only contains server mode, I installed a 32 bit JDK 8 and started using it in client mode, since then the RAM usage is about 80 MB.