I'm running a desktop system that quite regularly suffers from lack of memory, this prompted me to investigate what causes the issue in the first place.
Problem is, there's no single process that eats the memory, yet the system doesn't show it as available. What's more, the system does swap so it looks like the memory pressure is real. What's puzzling, is that the usage goes to normal (~1GB used) after I log out and back again so it looks like some weird interaction between userland and kernel and not a memory leak.
In short:
- memory reported as used by
free
, excluding cache/buffers: 3173960 kB - sum of USS of all applications: 2413952 kB
- SLAB size: 158968 kB
- zram (after compression): 75992 kB
That gives, 3173960-2413952-158968-75992 = 525048 kB
unaccounted memory usage.
What I'm missing or not counting?
Sum of applications memory usage:
# smem -t | sed -n '1p;$p'
PID User Command Swap USS PSS RSS
108 6 244524 2413952 2461340 2648488
Memory usage as reported by free
:
# free -k
total used free shared buffers cached
Mem: 4051956 3449748 602208 0 26548 249240
-/+ buffers/cache: 3173960 877996
Swap: 4051952 242592 3809360
General memory statistic:
# cat /proc/meminfo
MemTotal: 4051956 kB
MemFree: 612260 kB
Buffers: 26636 kB
Cached: 249304 kB
SwapCached: 107892 kB
Active: 1774004 kB
Inactive: 885268 kB
Active(anon): 1712484 kB
Inactive(anon): 710788 kB
Active(file): 61520 kB
Inactive(file): 174480 kB
Unevictable: 9332 kB
Mlocked: 9332 kB
SwapTotal: 4051952 kB
SwapFree: 3809368 kB
Dirty: 40 kB
Writeback: 0 kB
AnonPages: 2343292 kB
Mapped: 95288 kB
Shmem: 36396 kB
Slab: 158968 kB
SReclaimable: 53900 kB
SUnreclaim: 105068 kB
KernelStack: 3528 kB
PageTables: 43600 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6077928 kB
Committed_AS: 4013288 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 139852 kB
VmallocChunk: 34359570976 kB
HardwareCorrupted: 0 kB
AnonHugePages: 641024 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 2310848 kB
DirectMap2M: 1882112 kB
Swaps are on zram
:
# cat /proc/swaps
Filename Type Size Used Priority
/dev/zram0 partition 2025976 121252 100
/dev/zram1 partition 2025976 121324 100
# awk ' { print $0 / 1024; sum+=$0 } END { print "sum:" sum/1024 } ' /sys/block/zram*/compr_data_size
37962.4
38030.1
sum:75992.5
top
andslabtop
would be necessary. – Huygens Mar 04 '13 at 07:51