Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce Unused Heap size in JVM

This has been asked similarly here and here but neither changes to the JVM parameters has lead me to the same solution. I simply want to reduce my JVM's unused heap size, so that it more closely reflects actual usage (freeing it to the OS). I've been using YourKit to profile the memory usage and it typically looks like this:

enter image description here

I'm running intellIj IDEA Community Edition 64-bit, on Windows 7 64-bit, 8 GB RAM. I've edited the .vmoptions file found here: C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.5\bin\idea64.exe.vmoptions with the suggestions mentioned in the links above. The first link's answer is actually wrong/out-dated, but 2 comments link to articles found here and here which seem promising. The thing is, I've tried all of the different Garbage Collectors mentioned, and still see a similar (not identical) heap size shown above.

How do I reduce allocated heap size (olive green) to more accurately reflect the actual usage (blue)? Shouldn't Garbage Collection lower the heap size, not increase it like currently.

I've tried configuring my idea64.exe.vmoptions as follows:

As per the last link above, it claims

Only the Serial GC and G1 release unused memory to the OS

It even visually shows how the heap is reduced. Yet I've had no luck and have tried all of the following: What's going on??

-XX:+UseSerialGC

and

-XX:-UseSerialGC

and

-XX:+UseG1GC

and

-XX:-UseG1GC

and

Both of the above together, with and without ("+/-")

and

-XX:-UseAdaptiveSizePolicy
-XX:-UseParallelGC

and

-XX:UseConcMarkSweepGC

and

-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false

and

-server
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=150m
-XX:UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true

EDIT:

To reiterate why this isn't a duplicate, the other "answer" is 5 years old and fails to even mention any of the modern Garbage Collectors. The only helpful parts are the two links in the comments which point to different JVM parameters to use, all of which I've tried and don't have success with. I've tried those solutions in full, and still have no result. This is precisely why I'm urging you to consider this as unique, as others are likely experiencing the same circular frustration.

like image 989
Mathomatic Avatar asked Jul 10 '16 19:07

Mathomatic


1 Answers

As far as I know those are only for the editor itself. You should insert those setups in the following place:

Run > Edit Configurations... > VM options

The options should work if placed inside the programs vmoption.

like image 75
Hash Avatar answered Oct 13 '22 13:10

Hash