You are not logged in.

#1 2014-07-23 13:39:35

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

How to measure memory usage?

xorg-server 1.16 seems to use much more memory that the previous versions (and generally sucks ;P), but maybe just its memory use reporting has changed.

https://www.archlinux.org/packages/comm … ny/ps_mem/
https://github.com/pixelb/ps_mem/

It's a 32-bit system.

# ps_mem -p 362
 Private  +   Shared  =  RAM used	Program

333.9 MiB + -7156.5 KiB = 326.9 MiB	firefox
---------------------------------
                        326.9 MiB
=================================
# ps_mem -p 253
 Private  +   Shared  =  RAM used	Program

173.9 MiB +   2.0 MiB = 175.9 MiB	Xorg.bin
---------------------------------
                        175.9 MiB
=================================
# free -m
             total       used       free     shared    buffers     cached
Mem:           997        861        135        174         44        442
-/+ buffers/cache:        374        622
Swap:          258          0        258

Can someone interpret these results for me?


Does using zswap has any effect on memory use reporting?

http://stackoverflow.com/questions/1313 … or-process or https://bbs.archlinux.org/viewtopic.php?id=184496 leave me with even more questions and a headache.

Offline

#2 2014-07-23 14:25:36

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: How to measure memory usage?

doesn't look good compared to 1.15.2-1 on x86_64:

# ps_mem -p 588
 Private  +   Shared  =  RAM used	Program

 13.2 MiB +   5.9 MiB =  19.2 MiB	Xorg
---------------------------------
                         19.2 MiB
=================================

I don't know how you want your results interpreted. Looks like ps_mem should report actual per application memory usage quite accurately.

it's been my impression that zswap usage doesn't show up as swap in free or other memory usage monitors, so the zswap pool would probably show up as cached mem.
I haven't confirmed this in any way, but I've noticed that after enabling zswap my system barely uses swap any more.

Offline

#3 2014-07-23 14:50:15

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

Re: How to measure memory usage?

I've noticed a bit of slowdown when the swap needs to be populated, but it's not at all bad, no thrashing.
swap use will depend on swappiness and vfs_cache_pressure settings.


Firefox and X use over half of available RAM, yet 'free' reposts only 374 MB being used. Why is that?

Offline

#4 2014-07-23 15:02:16

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: How to measure memory usage?

karol wrote:

Firefox and X use over half of available RAM, yet 'free' reposts only 374 MB being used. Why is that?

good point. That actually could be caused by zswap, if it is displayed as 'cached' memory as I'm suspecting, and it was actually being used at the time (/sys/kernel/debug/zswap/stored_pages > 0).

Offline

#5 2014-07-23 15:12:05

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

Re: How to measure memory usage?

If you want me to test something, please tell me how exactly and what should I do.

# swapon -s
Filename				Type		Size	Used	Priority
/dev/sda2                              	partition	265068	0	-1
# cat /sys/kernel/debug/zswap/stored_pages
0
# grep . /sys/kernel/debug/zswap/*
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/pool_limit_hit:0
/sys/kernel/debug/zswap/pool_pages:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/stored_pages:0
/sys/kernel/debug/zswap/written_back_pages:0

Offline

#6 2014-07-23 15:28:11

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: How to measure memory usage?

What does "smem -kt" show, karol?

Stuff in zswap shows (used to?) as used swap and is also counted in the "used" field, I think (conversely, stuff in tmpfs is counted as cache, if I am not mistaken). You can indeed see debug info about it in /sys/kernel/debug/zswap/.

Did Xorg 1.16 change the name of its process from X to Xorg.bin?

xrestop can show some info about X server's memory usage.

Offline

#7 2014-07-23 15:42:24

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: How to measure memory usage?

karol wrote:

# cat /sys/kernel/debug/zswap/stored_pages
0

well.. basically this means there are no pages stored in zswap pool at the time.

my understanding is that zswap pool isn't included in used mem -buffers/cached.
if some memory allocated by Xorg or firefox were zswapped, that would have an effect on the 'free' ouput, but apparently this is not the case.

EDIT: did some testing: apparently zswap shows up as used swap after all. thanks to lucke for correction.
sorry about that :(

Last edited by ooo (2014-07-23 15:55:03)

Offline

#8 2014-07-23 15:50:19

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

Re: How to measure memory usage?

I'm scratching my head and banging it against the wall. I've developed a nice rhythm ;-)


It's Xorg.bin now:

$ pacman -Qo Xorg.bin
/usr/bin/Xorg.bin is owned by xorg-server 1.16.0-2
$ smem -kt
  PID User     Command                         Swap      USS      PSS      RSS 
  315 karol    dwmst                              0   160.0K   272.0K     2.1M 
  296 karol    xinit /home/karol/.xinitrc         0   176.0K   279.0K     1.9M 
  516 karol    dbus-launch --autolaunch=0d        0   244.0K   347.0K     1.9M 
  279 karol    /bin/sh /usr/bin/startx            0   292.0K   413.0K     2.9M 
  522 karol    /usr/bin/dbus-daemon --fork        0   216.0K   479.0K     1.9M 
  300 karol    dwm                                0   336.0K   562.0K     3.1M 
  263 karol    /usr/lib/systemd/systemd --        0   408.0K   923.0K     3.1M 
  419 karol    bash                               0   848.0K   995.0K     3.8M 
  411 karol    bash                               0   860.0K  1004.0K     3.8M 
 2850 karol    bash                               0   860.0K  1007.0K     3.9M 
 3651 karol    bash                               0   864.0K  1011.0K     3.8M 
  422 karol    bash                               0   852.0K  1016.0K     4.0M 
  417 karol    bash                               0   856.0K  1017.0K     3.9M 
  267 karol    -bash                              0   856.0K  1018.0K     3.9M 
  425 karol    bash                               0   852.0K  1019.0K     4.0M 
  415 karol    bash                               0   856.0K  1021.0K     3.9M 
  330 karol    -bash                              0   860.0K  1022.0K     4.0M 
  443 karol    vim -p 0                           0     4.0M     4.1M     6.7M 
 5934 karol    python2 /usr/bin/smem -kt          0     5.3M     5.4M     7.3M 
  316 karol    urxvtd                             0    22.7M    25.5M    33.1M 
  573 karol    /usr/lib/firefox/plugin-con        0    22.0M    32.7M    48.0M 
  297 karol    /usr/bin/Xorg.bin -nolisten        0   123.7M   124.8M   128.9M 
  452 karol    firefox                            0   232.0M   245.9M   265.4M 
-------------------------------------------------------------------------------
   23 1                                           0   419.8M   451.5M   545.5M 
$ sudo ps_mem
 Private  +   Shared  =  RAM used	Program

116.0 KiB +  44.0 KiB = 160.0 KiB	atd
144.0 KiB +  52.5 KiB = 196.5 KiB	vnstatd
164.0 KiB +  33.5 KiB = 197.5 KiB	gpm
156.0 KiB +  48.5 KiB = 204.5 KiB	acpid
188.0 KiB +  63.0 KiB = 251.0 KiB	systemd-resolved
160.0 KiB + 127.0 KiB = 287.0 KiB	dwmst
176.0 KiB + 119.5 KiB = 295.5 KiB	xinit
244.0 KiB + 121.0 KiB = 365.0 KiB	dbus-launch
292.0 KiB + 131.0 KiB = 423.0 KiB	startx
336.0 KiB + 249.0 KiB = 585.0 KiB	dwm
644.0 KiB +  67.0 KiB = 711.0 KiB	systemd-networkd
672.0 KiB +  72.5 KiB = 744.5 KiB	systemd-logind
932.0 KiB + 120.0 KiB =   1.0 MiB	systemd-udevd
736.0 KiB + 419.5 KiB =   1.1 MiB	(sd-pam)
552.0 KiB + 659.0 KiB =   1.2 MiB	dbus-daemon (2)
876.0 KiB + 587.0 KiB =   1.4 MiB	su (3)
  1.2 MiB + 378.5 KiB =   1.6 MiB	sudo
944.0 KiB + 712.0 KiB =   1.6 MiB	login (2)
996.0 KiB +   1.3 MiB =   2.2 MiB	systemd (2)
  4.0 MiB + 195.5 KiB =   4.2 MiB	vim
  8.1 MiB + 109.0 KiB =   8.2 MiB	systemd-journald
 11.1 MiB +   2.1 MiB =  13.2 MiB	bash (13)
 26.1 MiB +   5.6 MiB =  31.6 MiB	urxvtd (3)
 20.9 MiB +  11.4 MiB =  32.3 MiB	plugin-container
123.7 MiB +   1.2 MiB = 124.9 MiB	Xorg.bin
230.7 MiB +  14.2 MiB = 244.9 MiB	firefox
---------------------------------
                        473.9 MiB
=================================

Wrt xrestop, how do you drive this thing?

Offline

#9 2014-07-23 16:09:26

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: How to measure memory usage?

Install xrestop, run xrestop (if it works with X 1.16), look at the "Pixmaps:" line.

Offline

#10 2014-07-23 16:30:33

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

Re: How to measure memory usage?

xrestop - Display: localhost:0
          Monitoring 11 clients. XErrors: 0
          Pixmaps:   33867K total, Other:      36K total, All:   33903K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier    
0c00000    43   36    1  147  339    23118K     10K  23129K   452 Library
0000000     1    0    2    0   84    10060K      3K  10063K   ?   CPU 7% MEM 354 851 VOL 1% Wed Jul 23 18:
0800000    20   11    5   10  116      598K      8K    607K   316 urxvt
0400000     1    2    5    1  277       90K     11K    101K   ?   <unknown>
1000000     5   26    0    1   10       12B    984B    996B   573 plugin-container
1200000     1    3    0    0    7        0B    264B    264B  8392 mpv - foobar.mp4
1400000     1    1    0    0    0        0B     48B     48B   ?   xrestop
0a00000     1    1    0    0    0        0B     48B     48B   ?   <unknown>
0e00000     0    1    0    0    0        0B     24B     24B   ?   <unknown>
0600000     0    1    0    0    0        0B     24B     24B   ?   <unknown>
0200000     0    1    0    0    0        0B     24B     24B   ?   <unknown>

Does this mean X is using just 33 MB?

Offline

#11 2014-07-23 16:56:23

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: How to measure memory usage?

Well, in my case xrestop shows total of pixmaps slightly greater than the RSS of X shown by smem ;-) Hm, maybe not if you take swapped out parts into account.

If something is leaking memory and X's memory usage is steadily increasing, it can (usually?) be seen in xrestop. Other than that, I don't exactly know what's the relationship of data shown by xrestop to X's and other processes' memory usage.

What's your GPU/driver? What's your resolution? It can have an impact on memory usage, I presume. Using a compositing window manager might change things too.

Last edited by lucke (2014-07-23 16:58:47)

Offline

#12 2014-07-23 17:25:12

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

Re: How to measure memory usage?

I'm using dwm, need no stinkin' composting manager.

$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device (rev 01)

@1280x1024, xf86-video-intel 2.99.912-4.

Offline

#13 2014-07-23 17:30:36

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: How to measure memory usage?

There's 2.99.913 in the testing repo now, maybe it makes a difference.

Offline

#14 2014-07-23 17:48:06

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

Re: How to measure memory usage?

I'm using my version of dwmst, which I took IIRC from Unia: https://github.com/Unia/dwmst I'll go w/o and see if it makes a difference.
(I think) xrestop shows it uses a lot of mem (it's the second line, between 'Library' and 'urxvt').

Offline

#15 2014-07-25 18:18:00

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

Re: How to measure memory usage?

I think my dwmst script was leaking / hogging memory.
now ps_mem and 'free -m' show the same amount of memory used, Xorg.bin uses 10-15 MB.

Offline

Board footer

Powered by FluxBB