How does the SSM calculate the boundary condition for AvailableVirtualAddressSpace on 32-bit RHEL?

The SSM uses the following algorithm to calculate available virtual memory: (2G – usedVirMem + VirMemHeldByLibc) / 2G

where:

usedVirMem is the size of memory allocated by the OS and VirMemHeldByLibc is the size of memory held by libc as cache, which is intended to improve the malloc/calloc/free call performance.

When we call free() in C to release memory, sometimes it just returns to libc rather than to the OS immediately. Libc decides when the memory should be returned to the OS. Since the memory held by libc is considered as cache that can be reused, we get usedVirMem = virMemRealUsedBySsm + VirMemHeldByLibc. So the remaining SSM memory that can be used is (2G-(usedVirMem-VirMemHeldByLibc)), which is (2G – usedVirMem + VirMemHeldByLibc).