You are not logged in.

#1 2014-10-19 03:01:45

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

[solved] ps_mem bug?

$ sudo ps_mem
 Private  +   Shared  =  RAM used       Program

140.0 KiB +  38.5 KiB = 178.5 KiB       vnstatd

<snip>

  3.3 MiB +  75.5 KiB =   3.4 MiB       systemd-journald
  5.4 MiB +   2.1 MiB =   7.4 MiB       st (4)
 31.9 MiB + -9631.5 KiB =  22.5 MiB     Xorg.bin
292.4 MiB + -30818.5 KiB = 262.3 MiB    firefox
---------------------------------
                        312.3 MiB

Shared memory for X and firefox should be displayed in MB, but maybe the script got fooled because it's a negative value?

I found no reports about it upstream. Can somebody have a look at it? Unfortunately I don't speak python.
https://github.com/pixelb/ps_mem/ -> https://raw.githubusercontent.com/pixel … /ps_mem.py
You can install ps_mem package from the official repos.

Last edited by karol (2014-10-19 20:09:04)

Offline

#2 2014-10-19 20:08:54

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] ps_mem bug?

Easier than I thought.

Before:

$ sudo ps_mem -p 10606,7171
 Private  +   Shared  =  RAM used       Program

366.3 MiB + -3939.5 KiB = 362.4 MiB     mpv
445.4 MiB + -29473.5 KiB = 416.6 MiB    firefox
---------------------------------
                        779.1 MiB
=================================

After:

$ sudo ps_mem -p 10606,7171
 Private  +   Shared  =  RAM used       Program

366.3 MiB +  -3.9 MiB = 362.4 MiB       mpv
444.0 MiB + -28.8 MiB = 415.2 MiB       firefox
---------------------------------
                        777.7 MiB
=================================

No idea if it breaks anything, but

$ diff /usr/bin/ps_mem ps_mem
--- /usr/bin/ps_mem     2014-10-19 20:06:26.648456437 +0000
+++ ps_mem      2014-10-19 20:06:37.625063638 +0000
@@ -293,7 +293,7 @@
 #see also human.py
 def human(num, power="Ki"):
     powers = ["Ki", "Mi", "Gi", "Ti"]
-    while num >= 1000: #4 digits
+    while abs(num) >= 1000: #4 digits
         num /= 1024.0
         power = powers[powers.index(power)+1]
     return "%.1f %s" % (num, power)

seems to work.

Offline

#3 2014-10-19 20:19:29

ids1024
Member
From: California
Registered: 2013-08-16
Posts: 243
Website

Re: [solved] ps_mem bug?

Should it really have a negative value? I don't see how a program could use a negative amount of RAM...


"Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it."—Linus Torvalds
s/ftp/git/

https://iandouglasscott.com | https://github.org/ids1024 | https://keybase.io/ids1024

Offline

#4 2014-10-19 20:22:44

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] ps_mem bug?

ids1024 wrote:

Should it really have a negative value? I don't see how a program could use a negative amount of RAM...

I've seen negative values only for the shared memory, private memory and total amount are positive.



Opened a bug report: https://github.com/pixelb/ps_mem/issues/9

Offline

#5 2014-10-20 09:35:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] ps_mem bug?

You may be onto something. ps_mem dev says it's a kernel bug: https://lkml.org/lkml/2014/10/9/109

Offline

Board footer

Powered by FluxBB