4 ms·
Basically, the memory management on modern computers with virtual memory has to self-impose some constraints to create internal pressure to clean up memory. The
by kazinator 7y ago
Basically, the memory management on modern computers with virtual memory has to self-impose some constraints to create internal pressure to clean up memory. The implementation may have the option to set some absolute maximum heap size. Or other parameters that set growth hurdles. The memory management tries to keep things within a given hurdle, but when it's obvious that more memory is needed, it changes to another hurdle: e.g. it allocates a new heap area from the OS with a big allocation.
There is a performance trade off there, because if lots of memory is available, but we tighten the belt anyway, the application may perform less well due to running garbage collection when it could have gotten away with allocating more external memory. On the other hand, the application is then less of a "pig" with regard to other things in the system.