Re: Calculating private and shared memory for processes
On Fri, Feb 10, 2023 at 5:43 PM Rahul Gore (Nokia) 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 | 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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Calculating private and shared memory for processes
Hello, Just wanted to follow up on this question. Please let me know if I'm missing anything basic that I need to do to solve this problem. Regards, Rahul From: Rahul Gore (Nokia) Sent: Friday, February 10, 2023 2:43 PM To: kernelnewbies@kernelnewbies.org Subject: Calculating private and shared memory for processes Hi, I'm trying to find private and shared memory usage of each process in Linux. One answer on Stack Overflow suggested using 'smem' utility (it reads /proc//smap). However, the sum of all PSS values in 'smem' output is not equal to Used value of the 'free' utility (it reads /proc/meminfo). CLI output: $ sudo smem -t | tail -n 5 2950301 1002 gfstandalone_1_0 --test hw/0 1427244 1435899 1453060 2950368 1002 gfstandalone_1_1 --test hw/0 1432172 1440818 1457588 3012185 rgorejava -classpath /home/rgore0 2159256 2159348 2163268 --- 537 23 702168 2474 26865451 62093364 $ free -w totalusedfree shared buffers cache available Mem:6562503626415500 511020 351372 1541640 3715687638119868 Swap:2097148 726148 1371000 So, I doubt the accuracy of the values in /proc//smap. Is there a more reliable alternative? Regards, Rahul ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Calculating private and shared memory for processes
Hi, I'm trying to find private and shared memory usage of each process in Linux. One answer on Stack Overflow suggested using 'smem' utility (it reads /proc//smap). However, the sum of all PSS values in 'smem' output is not equal to Used value of the 'free' utility (it reads /proc/meminfo). CLI output: $ sudo smem -t | tail -n 5 2950301 1002 gfstandalone_1_0 --test hw/0 1427244 1435899 1453060 2950368 1002 gfstandalone_1_1 --test hw/0 1432172 1440818 1457588 3012185 rgorejava -classpath /home/rgore0 2159256 2159348 2163268 --- 537 23 702168 2474 26865451 62093364 $ free -w totalusedfree shared buffers cache available Mem:6562503626415500 511020 351372 1541640 3715687638119868 Swap:2097148 726148 1371000 So, I doubt the accuracy of the values in /proc//smap. Is there a more reliable alternative? Regards, Rahul ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies