The intention of the soft reference heuristics is to increase eagerness of clearing soft references, as the amount of free memory in the heap gets smaller. The implementation of the soft reference policy takes the Heap()->free_at_last_gc() and multiplies by a hilarious JVM flag.
What this does is to take the capacity and subtract the used memory from that. This works great for a STW GC. After a full GC, the amount of free memory that is not live, is basically the capacity minus the used memory.
In a very concurrent GC such as ZGC, there could be 20 young generation collections during an old generation collection, that cause the used memory to go up and down in a large saw tooth pattern that covers most of the heap capacity. The policy will capture some random point on this saw tooth function, and draw some rather inaccurate and arbitrary conclusions about how much memory was not live in the heap, and then use that to define a reasonable interval at which we need to wait for soft references to time out and get reaped.
As a consequence, the clearing of soft references might completely randomly be way more aggressive than reasonable. This maps poorly to the initial idea of measuring some kind of memory pressure.
What this does is to take the capacity and subtract the used memory from that. This works great for a STW GC. After a full GC, the amount of free memory that is not live, is basically the capacity minus the used memory.
In a very concurrent GC such as ZGC, there could be 20 young generation collections during an old generation collection, that cause the used memory to go up and down in a large saw tooth pattern that covers most of the heap capacity. The policy will capture some random point on this saw tooth function, and draw some rather inaccurate and arbitrary conclusions about how much memory was not live in the heap, and then use that to define a reasonable interval at which we need to wait for soft references to time out and get reaped.
As a consequence, the clearing of soft references might completely randomly be way more aggressive than reasonable. This maps poorly to the initial idea of measuring some kind of memory pressure.