Should I reset the Java heap space after use?

I'm using some modeling algorithms in R, one of which runs in Java (bartmachine) I found that before running the modeling algorithm, I need to increase the maximum heap space of Java according to the size of the data

I did this:

options(java.parameters =“ – Xmx16g”)

My question is, if no other algorithm will use Java (or at least so much heap space), do I need to reset the heap space? Or reclaim the memory allocated to Java as needed without losing performance?

I've searched some content on this topic, and I know how to change / reduce heap space I also understand that R / Java will do garbage collection to delete old objects from memory to free up more space

What I don't understand is how changing the heap space will affect the memory available to other programs, and whether it is necessary or even a good idea to change the heap size after use in this case

Some answers / resources I've seen:

Is there a way to lower Java heap when not in use?

Java garbage collector – When does it collect?

http://www.bramschoenmakers.nl/en/node/726

https://cran.r-project.org/web/packages/bartMachine/bartMachine.pdf

Solution

Its implementation is defined and depends on the implementation affected by many parameters The garbage collector can affect it. On Macs using Oracle JVM 1.7, the default is parallel Collector - XX: useparallelgc, which will not release memory back to the operating system I tried it on the Mac and didn't release anything except - XX: useg1gc You can view the default version using the following:

java -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -version

If you use a JVM that supports it and the correct garbage collector, you can use some parameters to adjust the way memory is freed, that is

-XX:MinHeapFreeRatio (default is 40)
-XX:MaxHeapFreeRatio (default is 70)

But they are hit and missed (the JVM decides when to free memory, freeing only a large number of objects may not trigger it)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>