Memory usage in an AMR run can be quite uneven between MPI ranks and also tends to peak during a regrid. See
#2194 for a case study. The growth in RSS can eventually lead to OOM situations as memory is not returned to the OS for use by other processes. Using the (GNU extension)
malloc_trim can help make the
malloc code return memory to the OS. Since this somewhat slows down future
malloc calls, since a new allocation will require a round trip to the kernel, this should not done after every single
free call but likely only after a regrid which entails a temporary spike in memory usage. Possible also after IO if the memory used to send data to rank 0 for writing becomes an issue (see #1853).
Similar effects to calling
malloc_trim can be achieved by setting env variables as mentioned in