This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Tip on /proc/self/maps and troubleshooting memory leaks

Tags: None
(comma "," separated)
americangentile
Registered Member
Posts
10
Karma
0
Recently I had to trouble shoot an annoying memory leak occurring in the plasmashell task. I have come across some helpful information in troubleshooting which might be able to help out.

As I have been learning on troubleshooting memory leaks, I came across this wonderful tool, see https://github.com/DataDrake/proc-maps.

Another informative site was https://www.fatalerrors.org/a/brief-analysis-of-memory-management-proc-pid-maps.html which is a good explanation of what is going on and what information the /proc/self/maps or /proc/pid/maps provides.

The pertinant information states:
Examine a single process

The rank-sizes subcommand reads through the map of a single running process and consolidates every mapped file into a single table sorted in descending order by size. Cumulative Size represents all of the memory used up to and including that file. These sizes are only for the mapped file and do not include allocations made by binary or library execution.

Command

sudo proc-maps rs 856
sudo proc-maps rank-sizes 856


I enclose a simple script file I created which creates a log every so many seconds apart, it is a bash script
Code: Select all
#!/bash
if [ -z $1 ]; then
  echo "Need loops to run"
  exit
fi
loops=$1
ct=0
pid=`pgrep plasmashell`
echo "plasmashell pid: $pid"
while [ $ct -lt $loops ] ; do
  fn="plasmashell.$ct.log"
  dt=`date`
  echo "Logged to $fn at $dt"
  ##cat /proc/$pid/maps > $fn
  ##cat /proc/$pid/smaps > $fn
  ##cat /proc/meminfo > $fn
  sudo proc-maps rs $pid > $fn
  echo "---------------------------------------------------------------" >> $fn
  ct=`expr $ct + 1`
  if [ $ct -eq $loops ] ; then exit; fi;
  if [ $ct -gt $loops ] ; then exit; fi;
  sleep 60
done

You can run two or three snapshots, then do a "diff" or "meld" upon the files to see what has changed. You are welcome to use this bash script as you wish and modify to your desire. I set it to work with the "plasmashell" task, but you can change it to any task on your system experiencing problems. Using the information in the /proc/self/maps folder is a great help to locating memory issues such as leaks.

In my case, I was getting closer to understanding where the leak is occurring, it occurs in a certain section of the maps file
Code: Select all
7f6b30257000-7f6b3025c000 r--s 00000000 00:35 2650                       /home/owner/.cache/plasmashell/qmlcache/2feae45af152d292b6dad5698996e37d82bb6b65.qmlc
7f6b3025c000-7f6b3027c000 r-xp 00000000 00:2e 496605                     /usr/lib64/qt5/qml/org/kde/taskmanager/libtaskmanagerplugin.so
7f6b3027c000-7f6b3047b000 ---p 00020000 00:2e 496605                     /usr/lib64/qt5/qml/org/kde/taskmanager/libtaskmanagerplugin.so
7f6b3047b000-7f6b3047d000 r--p 0001f000 00:2e 496605                     /usr/lib64/qt5/qml/org/kde/taskmanager/libtaskmanagerplugin.so
7f6b3047d000-7f6b3047e000 rw-p 00021000 00:2e 496605                     /usr/lib64/qt5/qml/org/kde/taskmanager/libtaskmanagerplugin.so
7f6b3047e000-7f6b30e7e000 rwxp 00000000 00:00 0
7f6b30f63000-7f6b30fdb000 rw-s 00000000 00:01 17825800                   /SYSV00000000 (deleted)
7f6b30fdb000-7f6b30fdf000 r-xp 00000000 00:00 0
7f6b30fdf000-7f6b30fe0000 rw-p 00000000 00:00 0
7f6b30fe0000-7f6b30fe6000 r-xp 00000000 00:00 0
7f6b30fe6000-7f6b30fe7000 rw-p 00000000 00:00 0
7f6b30fe7000-7f6b30fef000 r-xp 00000000 00:00 0

The problem line is this one:
7f6b30f63000-7f6b30fdb000 rw-s 00000000 00:01 17825800 /SYSV00000000 (deleted)

where the size in red font keeps slowly increasing over time. Unfortunately the SYSV00000000 segment is apparently in virtual memory so more careful troubleshooting is needed, but the previous lines prior to this one give a hint as to the possible problem area.

I hope the information given above will give you more understanding of how to troubleshoot memory leakage issues and give you some tools on how to analyze and proceed in these thorny complicated detailed issues.
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
Could you please also file a bug for this? There shouldn't be any memory leaks to start with, so please file a bug on https://bugs.kde.org to let the developers know about your findings


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]