You are not logged in.

#1 2020-09-10 05:02:08

r2d2
Member
From: Planet Earth - The Internet
Registered: 2018-02-06
Posts: 4

How to find which software is leaking memory?

I'm having issue since are recent kernel update. I need to reboot my pc after about 24h since the RAM slowly get full. I tried using htop but I see nothing unusual.

What could I use to find out which software is slowly using all RAM over a period of time?

Offline

#2 2020-09-10 06:42:04

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,705

Re: How to find which software is leaking memory?

https://www.kernel.org/doc/html/latest/ … mleak.html
But beware: https://www.linuxatemyram.com/

Trace the development of  /proc/meminfo between "empty RAM" and "RAM gone" ("free -h" for a more general but less precise overview) and also just try to drop file caches, https://www.tecmint.com/clear-ram-memor … -on-linux/

Offline

#3 2020-09-10 07:26:11

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: How to find which software is leaking memory?

$ free -h
$ df -h -t tmpfs
$ Wait for about 20 hours
$ htop followed by F6 sort by

Since you are not stated which kernel version you are using and no other people repported recent kernel memory leak issue yet. I assume the problem is related to user space application you are using.
First make a record on how many memory do you have after system booted. Due to tmpfs occupy a certain percentage, you may only left with 2/3 of total memory to start with.
After your system has been up for about 20 hours without terminating any
application, without free any cache memory by hand. Then run htop followed by F6 and sort by M_SIZE (size of the virtual memory of the process), M_RESIDENT ( physical memory) and M_SHARE (shared pages).

Last edited by solskog (2020-09-10 07:34:45)

Offline

#4 2020-09-10 08:55:34

Wild Penguin
Member
Registered: 2015-03-19
Posts: 406

Re: How to find which software is leaking memory?

seth wrote:

That site is a bit outdated. This used to be true (and, well, kind of still is), however they changed the output of 'free' to be more user-friendly, i.e. reflect what most users (and common sense) would expect while not losing any information.

For example on my system:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           31Gi       4,8Gi       970Mi       568Mi        25Gi        25Gi
Swap:          31Gi          0B        31Gi

So, "Used" is actually just the parts used by Kernel+Userspace programs. I'm not actually sure when this changed, but this used to be different.  Might also be a system-wide setting somewhere?

Rest of the output has not changed. "Free" is still low(er to what many might expect), however still reflects the "free" as in non-allocated RAM (as it used to). Shared, buff/cache and available -fields have not changed. Also, another thing on that side which is outdated is using "free -m". That output is not that user friendly / easy to read anymore, now that RAM size is usually measured in GiB rather than MiB.

Also, most desktop environments system monitors (GUIs) will report "free RAM" in a form most (layman) desktop users would expect.

Also, OP didn't state if the leak is in some application or in Kernel. Indeed your tips are fine for looking in-Kernel leaks, and solskog tips are better for looking at applications RAM usage.

During the ~20 years I've been using some form of Linux as my daily driver, IIRC I've encountered an in-Kernel memory leak once. IIRC it was with the proprietary fglrx driver (or some other proprietary component), but looking at the  /sys/kernel/debug/kmemleak was in no way easy to interpret or determine the source or helpful in giving input for a bug report. Luckily, it was a nuisance for only a few days as the leak was promptly fixed (IIRC, but it's was a long time ago in a galaxy far, far away... so, some details might be wrong. For example, I'm not sure which galaxy it was, might have been a bit nearer).

User-space program memory leaks are different, and indeed do show up as "regular" memory usage (always?).

Last edited by Wild Penguin (2020-09-10 10:29:44)

Offline

#5 2020-09-10 09:12:02

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,705

Re: How to find which software is leaking memory?

OP didn't say how he measures memory usage, could be some useless desktop widget.(and the link more or less to raise awareness of the file cache - i didn't read the page)

Since this apparently started w/ a kernel update and he asserts "nothing unusual" in userspace, the leak (if true) will be in kernelspace (though indeed could just be sth. spamming a tmpfs and yes: kernel leaks are rare and usually happen in exotic modules)

Offline

#6 2020-09-10 10:33:00

Wild Penguin
Member
Registered: 2015-03-19
Posts: 406

Re: How to find which software is leaking memory?

You are right, of course. There's very little information in the op, so it is impossible to say what is actually going on.

Offline

#7 2020-10-25 02:00:48

r2d2
Member
From: Planet Earth - The Internet
Registered: 2018-02-06
Posts: 4

Re: How to find which software is leaking memory?

seth wrote:

OP didn't say how he measures memory usage, could be some useless desktop widget.(and the link more or less to raise awareness of the file cache - i didn't read the page)

Since this apparently started w/ a kernel update and he asserts "nothing unusual" in userspace, the leak (if true) will be in kernelspace (though indeed could just be sth. spamming a tmpfs and yes: kernel leaks are rare and usually happen in exotic modules)

I only tried using htop once my browser crash and I notice I'm out of memory but I don't understand what is using it. If I use the lts kernel I don't have issue and strangely it coincides with the recent Virtualbox problems which is always running. I tried the standard kernel after several updates and the problem persist so I'm using lts for now.

Last edited by r2d2 (2020-10-25 02:02:51)

Offline

#8 2020-10-25 09:11:44

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,705

Re: How to find which software is leaking memory?

You could try whether it's https://bbs.archlinux.org/viewtopic.php?id=258217 by not running VB (and ideally not loading its modules) on the main kernel and monitor your RAM.

Offline

Board footer

Powered by FluxBB