Page 1 of 1

LFD should use resident memory instead of virtual memory

Posted: 12 Aug 2012, 05:54
by mikerobinson
Virtual memory doesn't cost anything. I could have a process that maps a large file on my hard drive and this will be through the roof. I got the following error today:
Time: Sat Aug 11 21:59:45 2012 -0600
Account: mike
Resource: Virtual Memory Size
Exceeded: 1110 > 1000 (MB)
Executable: /usr/bin/kmix
Command Line: /usr/bin/kmix -session 10108152142da000133799057900000022270010_1344454058_238350
PID: 2675
Killed: No
However KDE system activity reports this PID as only using ~8 MB and the total private + shared memory is ~14 MB:
$ cat /proc/2675/status | grep VmRSS
VmRSS: 14704 kB
Should I really be worried if a process is eating up gigabytes of virtual memory? I would be much more concerned if that was resident memory. So my suggestion would be to either use resident memory instead of virtual memory, or provide an option for each. In the KDE system activity it even says about the virtual memory usage: "this number is almost meaningless".

Re: LFD should use resident memory instead of virtual memory

Posted: 14 Aug 2012, 04:11
by mikerobinson
The fix is super simple:

In /usr/sbin/lfd, line 3106 change:

Code: Select all

if ($line =~ /^VmSize:\s+(\d+) kB$/) {$vmsize = $1}
to:

Code: Select all

if ($line =~ /^VmRSS:\s+(\d+) kB$/) {$vmsize = $1}
and line 3342, change:

Code: Select all

$resource = "Virtual Memory Size";
to:

Code: Select all

$resource = "Memory Usage (RSS)";
And if you want, change all occurrences of the variable $vmsize to $vmrss.

Re: LFD should use resident memory instead of virtual memory

Posted: 14 Aug 2012, 05:24
by mikerobinson
Since there are many people who already have csf/lfd installed, I would assume that the above fix would not be the best idea since virtual memory usage tends to be significantly higher than physical memory usage, so making the above changes would likely mean that many processes should be killed but aren't. I would think that adding another option (e.g. PT_USERMEM_RSS) to the configuration file would be a much better idea. I would be more than willing to code this myself, however I don't see anywhere where you can commit code to the project, so I fear that it would be a waste of time. Please contact me if there is some way for me to add these changes and if this would be something that the dev(s) would be interested in having in the project.

Re: LFD should use resident memory instead of virtual memory

Posted: 06 Dec 2016, 11:22
by bouvrie
I vote +1 on the PT_USERMEM_RSS feature request as people tend to just put (php) processes on the ignore list to "get rid of the emails".

Reports that PHP scripts are infact using too much *resident* memory are much more helpful than reporting 'high' Virtual Memory. I would change my lfd script like mentioned above, only if it weren't for futuer LFD updates reverting the edit, and causing processes to be auto-killed (as Virtual Memory basically would always exceed the PT_USERMEM limit).

Re: LFD should use resident memory instead of virtual memory

Posted: 18 Jan 2017, 08:54
by ForumAdmin
A feature that addresses this has been added to csf v9.29 which we have just released:
http://blog.configserver.com/