How to check available VMSize with the process using jeMalloc

Prajakta praj.jagtap at
Fri Oct 16 12:18:55 PDT 2015

In my application I need to keep an eye on how much Virtual memory is
available for application to use.
I am able to get VM Upper limit for process by using getrlimit() (Getting
that limit as 15 GB).

If virtual memory for that process reaches to 14.5 GB (i.e. Now only 500 MB
VM is free.) we need to stop doing the processing.
So, I need to understand how much virtual memory is consumed by process at
any point.
In glibc, we were able to get that information using mallinfo().
Similar results I want to get using jemalloc. But, I am not getting exact

Below is the equation I am using to get free VM available:

1. Get maximum size of process's virtual memory (Getting this maxlimit as
15 GB)
2. For getting process's fixed part (Text + stack) : (This calculation will
be done only once)
     CodeSize = VMSize (Read of /proc/pid/status) - stats.mapped
   - I assume above equation will give us fixed part of process.
3. Check if low memory limit hits?
 if  (maxlimit - CodeSize - stats.allocated ) < 500 MB notify process is
running out of memory.

Please correct me if I am missing any counters or doing some wrong
assumptions in my calculation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the jemalloc-discuss mailing list