Jvm garbage collection too rare - clojure

I am developing a clojure application and it seems to use a lot more memory than it should. I thought it was a memory leak, but looking at it with jvisualvm it looks like the GC just doesn't work enough. The red outlines are where I manually called GC. Why does it allocate 300 MB when it seems to use about 30 MB?

+5
source share
3 answers

Make your pile smaller if you think it's too big. GC is launched only when necessary.

(The controls have changed over the years, but I think they still have an initial heap size, an increment size, and a maximum size. If your initial heap size is small, it will remain so small as there is no “high water mark” in using the heap which raises its height.)

+5
source

The JVM has parameters that govern memory management, including the amount initially allocated and the maximum amount to be allocated. In addition to these parameters, the JVM is not able to find out what you consider to be a reasonable amount of memory to use. As far as I know, there is no requirement for the JVM to start the GC on any particular schedule, and also not use any target amount of memory usage in the Java definition.

, , , JVM, , , 100 , 50 , . NEW, 1 . JVM GC? : , . ? . , GC?

Java, . , GC, , , ? , , , , . , .

+5

JVM . ~ 30 , , 60 . , ( ).

JVM Sun/Oracle. , -XX:NewSize=60m.

, - , . , , GC , , .

Update: Here is another information I found on setting heap sizes for a specific generation:

JVM setup: determining heap size values

+4
source

All Articles