changing jvm heap size - jgrasp

2019-06-12 21:15发布

问题:

I know how to increase java heap size on command line using flag -Xmx, I need to run my program in jgrasp, how do I increase the heap size for my program in that IDE?

System.out.println("---->"+Runtime.getRuntime().maxMemory());

prints ---->66650112

on adding flag -Xmx256m

the heap size still print the same number

回答1:

Even when you pass -Xmx256m, it doesn't mean that the JVM is going to allocate that amount right away. -Xmx specifies the max heap. The JVM will wait to allocate more heap up until that limit as it sees fit. If you want to specify the min heap and make sure you reach the limit right away, use -Xms256m.



回答2:

For increasing the memory of IDE itself, you will have to add those arguments to jgrasp_portable.bat or winconfig_portable.bat

However from your question it seems, you want to add memory to program running inside the IDE. For that, right click on project in jgrasp IDE, go to Compiler settings - this will open a small popup window in which choose compiler tab. There you have subtabs, choose "Flags/Args/Main", here you can add JVM heap sizes. As suggest in previous answer if you need more memory right on startup, it's better to mark -Xms and -Xmx both in appropriate size. Hope this helps