JAVA memory usage increases when app is used, but will not decrease when it is not used
I have a Java application that uses a lot of memory, but memory usage does not decline when the program is not used
Is there any way to force java to release this memory? Because this memory was not needed at that time, I can understand that in order to reserve a small amount of memory, but Java only reserves all the memory used It will reuse this memory again, but there must be a way to force java to free it when it is not needed
System. GC does not work
Solution
As pointed out in the comments, when the garbage collector processes objects, it is uncertain, and it will leave memories to the system
Maybe the tuning garbage collection outline provides a solution to your problem:
Otherwise, if you suspect that you are missing references, you can determine how to monitor heap leaks in the jvisualvm (a tool bundled with the standard SDK) You can use this program to perform heap dump and get the histogram of object memory consumption: