Calculating private and shared memory for processes

Jeffrey Walton noloader at gmail.com
Mon Feb 13 22:09:36 EST 2023


On Fri, Feb 10, 2023 at 5:43 PM Rahul Gore (Nokia) <rahul.gore at nokia.com> wrote:
>
> I’m trying to find private and shared memory usage of each process in Linux. ...

Application should _not_ share memory across processes. That's a
security vulnerability. One app could corrupt memory, and cause
unpredictable results in another process.

You can check for processes which share memory by looking for the
GNU_SHARED section attribute in a [on-disk] program. There should be
no shared sections.

Tobias Klein's checksec may show programs which have GNU_SHARED . If
checksec does not check for it, then `readelf -l <program> | grep
GNU_SHARED` should reveal it.

I'm guessing private memory usage is an easier problem. Profiling
tools probably provide it. Tools like 'perf mem' and Valgrind provide
the information.

Jeff



More information about the Kernelnewbies mailing list