Memory trimming
Under certain workloads, glibc can accumulate a significant amount of free memory in its allocation arena. This memory consumes physical memory as indicated by its usage of resident set size (RSS), which glibc does not always return to the operating system. High retention of physical memory by glibc—glibc memory bloat—can adversely affect other processes, and, under high workloads, can sometimes cause Vertica to run out of memory.
Vertica provides two configuration parameters that let you control how frequently Vertica detects and consolidates much of the glibc-allocated free memory, and then returns it to the operating system:
-
MemoryPollerTrimThreshold
: Sets the threshold for the memory poller to start checking whether to trimglibc
-allocated memory.The memory poller compares
MemoryPollerTrimThreshold
—by default, set to 0.83— with the following expression:RSS / available-memory
If this expression evaluates to a value higher than
MemoryPollerTrimThreshold
, then the memory poller starts checking the next threshold—set inMemoryPollerMallocBloatThreshold
—for glibc memory bloat.Note
On high-memory machines where very large Vertica RSS values are atypical, consider a higher setting forMemoryPollerTrimThreshold
. To turn off auto-trimming, set this parameter to 0. -
MemoryPollerMallocBloatThreshold
: Sets the threshold of glibc memory bloat.The memory poller calls glibc function
malloc_info()
to obtain the amount of free memory in malloc. It then comparesMemoryPollerMallocBloatThreshold
—by default, set to 0.3—with the following expression:free-memory-in-malloc / RSS
If this expression evaluates to a value higher than
MemoryPollerMallocBloatThreshold
, the memory poller calls glibc functionmalloc_trim()
. This function reclaims free memory from malloc and returns it to the operating system. Details on calls tomalloc_trim()
are written to system tableMEMORY_EVENTS
.For example, the memory poller calls
malloc_trim()
when the following conditions are true:-
MemoryPollerMallocBloatThreshold
is set to 0.5. -
malloc_info()
returns 15GB memory in malloc free. -
RSS is 30GB.
Note
This parameter is ignored ifMemoryPollerTrimThreshold
is set to 0 (disabled). -
Trimming memory manually
If auto-trimming is disabled, you can manually reduce glibc-allocated memory by calling Vertica function
MEMORY_TRIM
. This function calls malloc_trim()
.