Process self-exec and virtual memory size

Hello all,

To do a self-exec or self-restart of a process when it crosses the threshold memory limit, I use the value of virtual memory size field from /proc/$pid/stat file and do a self-exec.

According to man 5 proc

vsize %lu
             Virtual memory size in bytes.

I just want to know, whether calculating vmsize of the process is the right way to identify total memory consumption of a process? Should resident set size be taken into account or per process swap usage?

Pointers please.

That depends on your goal, is it RAM usage (rss) or virtual memory usage (vsize) (i.e. ram + swap space) ?

Virtual Size actually is swapped memory + non swapped memory (physical mem amount for executable code + for data)..
Additiniol your program can probability use libraries..for this kernel present shared librarys..And your program wants memory from SHR memory space..

So according to me you maybe can use pmap tool for threshold memory limit

pmap $pid