Re: Qemu-kvm is leaking my memory ???

Zdenek Kabelac
2008-03-19T15:05:52Z

2008/3/16, Avi Kivity <avi@qumranet.com>:
> Zdenek Kabelac wrote:
> > Hello
> >
> > Recently I'm using qemu-kvm on fedora-rawhide box with my own kernels
> > (with many debug options) I've noticed that over the time my memory
> > seems to disappear somewhere.
> >
> > Here is my memory trace after boot and some time of work - thus memory
> > should be populated.
> >
>
>
> No idea how these should add up. What does 'free' say?

Ok - here goes my free log (I'm loggin free prior each start of my qemu-kvm
so here is the log for this afternoon:
(I'm running same apps all the time - except during kernel compilation
I'm reading some www pages - and working with gnome-terminal - so some
slightly more memory could have been eaten by them - but not in the
range of hundreds of MB)

Wed Mar 19 12:54:38 CET 2008
total used free shared buffers cached
Mem: 2007460 1525240 482220 0 18060 469812
-/+ buffers/cache: 1037368 970092
Swap: 0 0 0
Wed Mar 19 13:27:51 CET 2008
total used free shared buffers cached
Mem: 2007460 1491672 515788 0 13024 404220
-/+ buffers/cache: 1074428 933032
Swap: 0 0 0
Wed Mar 19 13:51:38 CET 2008
total used free shared buffers cached
Mem: 2007460 1513000 494460 0 12676 366708
-/+ buffers/cache: 1133616 873844
Swap: 0 0 0
Wed Mar 19 14:05:30 CET 2008
total used free shared buffers cached
Mem: 2007460 1976592 30868 0 12220 785672
-/+ buffers/cache: 1178700 828760
Swap: 0 0 0
Wed Mar 19 14:13:52 CET 2008
total used free shared buffers cached
Mem: 2007460 1865500 141960 0 14592 633136
-/+ buffers/cache: 1217772 789688
Swap: 0 0 0
Wed Mar 19 14:16:04 CET 2008
total used free shared buffers cached
Mem: 2007460 1533432 474028 0 5852 304736
-/+ buffers/cache: 1222844 784616
Swap: 0 0 0
Wed Mar 19 15:05:33 CET 2008
total used free shared buffers cached
Mem: 2007460 1545796 461664 0 4100 276756
-/+ buffers/cache: 1264940 742520
Swap: 0 0 0
Wed Mar 19 15:14:07 CET 2008
total used free shared buffers cached
Mem: 2007460 1748680 258780 0 8324 427172
-/+ buffers/cache: 1313184 694276
Swap: 0 0 0

-now it's:
total used free shared buffers cached
Mem: 2007460 1784952 222508 0 20644 335360
-/+ buffers/cache: 1428948 578512
Swap: 0 0 0

and top-twenty memory list of currently running processes:

top - 15:52:29 up 19:07, 12 users, load average: 0.33, 0.30, 0.60
Tasks: 298 total, 1 running, 296 sleeping, 1 stopped, 0 zombie
Cpu(s): 1.6%us, 3.3%sy, 0.0%ni, 95.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2007460k total, 1770748k used, 236712k free, 20304k buffers
Swap: 0k total, 0k used, 0k free, 335036k cached

PID PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15974 20 0 655m 207m 28m S 0.0 10.6 3:31.31 firefox
3980 20 0 378m 63m 10m S 1.3 3.2 1:00.53 gnome-terminal
2657 20 0 481m 58m 9928 S 2.3 3.0 19:16.03 Xorg
12492 20 0 494m 34m 17m S 0.0 1.8 1:20.52 pidgin
3535 20 0 336m 22m 12m S 0.0 1.2 0:15.41 gnome-panel
3571 20 0 265m 16m 10m S 0.0 0.9 0:06.25 nm-applet
3638 20 0 298m 16m 9296 S 0.0 0.8 0:36.79 wnck-applet
3546 20 0 458m 16m 10m S 0.0 0.8 1:21.65 gnome-power-man
3579 20 0 261m 16m 8252 S 0.0 0.8 0:02.65 python
3532 20 0 200m 15m 8144 S 0.3 0.8 1:14.34 metacity
3754 20 0 325m 14m 9856 S 0.0 0.7 0:00.42 mixer_applet2
3909 20 0 243m 14m 7988 S 0.0 0.7 0:06.13 notification-da
3706 20 0 330m 14m 9764 S 0.0 0.7 0:01.40 clock-applet
3534 20 0 449m 13m 9884 S 0.0 0.7 0:00.92 nautilus
3540 20 0 250m 12m 8616 S 0.3 0.6 0:07.30 pk-update-icon
3708 20 0 300m 12m 7940 S 0.0 0.6 0:03.15 gnome-keyboard-
3752 20 0 290m 11m 8028 S 0.0 0.6 0:00.27 gnome-brightnes
3553 20 0 286m 11m 8144 S 0.0 0.6 0:04.29 krb5-auth-dialo
3761 20 0 270m 11m 7968 S 0.0 0.6 0:23.02 cpufreq-applet
2898 20 0 328m 10m 8240 S 0.0 0.5 0:07.95 gnome-settings-
3702 20 0 282m 9436 7460 S 0.0 0.5 0:00.25 drivemount_appl
3749 20 0 288m 8848 6924 S 0.0 0.4 0:00.11 gnome-inhibit-a
3756 20 0 274m 8704 6604 S 0.7 0.4 4:32.99 multiload-apple
3759 20 0 273m 7964 6416 S 0.0 0.4 0:00.33 notification-ar
2827 20 0 267m 6608 5304 S 0.0 0.3 0:00.18 gnome-session
31581 20 0 108m 5764 2000 S 0.0 0.3 0:00.82 gconfd-2
7934 20 0 110m 4960 2372 S 0.0 0.2 0:13.31 fte
3742 20 0 173m 4896 4004 S 0.0 0.2 0:00.40 pam-panel-icon
3531 20 0 215m 4824 3484 S 0.3 0.2 0:24.68 gnome-screensav
2421 20 0 34012 4628 3620 S 0.3 0.2 0:23.85 hald
29575 20 0 109m 4156 2272 S 0.0 0.2 0:00.21 fte
2904 9 -11 186m 3800 2964 S 0.3 0.2 1:37.88 pulseaudio
2752 20 0 176m 3688 2716 S 0.0 0.2 0:00.04 gdm-session-wor
3720 20 0 162m 3552 2932 S 0.0 0.2 0:00.13 gnome-vfs-daemo
2134 20 0 110m 3528 992 S 0.0 0.2 0:00.51 rsyslogd

$ cat /proc/meminfo
MemTotal: 2007460 kB
MemFree: 222332 kB
Buffers: 20780 kB
Cached: 335400 kB
SwapCached: 0 kB
Active: 981836 kB
Inactive: 532248 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 156 kB
Writeback: 0 kB
AnonPages: 493208 kB
Mapped: 73264 kB
Slab: 98552 kB
SReclaimable: 57796 kB
SUnreclaim: 40756 kB
PageTables: 43180 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 1003728 kB
Committed_AS: 2054396 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 68536 kB
VmallocChunk: 34359668731 kB

$ cat /proc/vmstat
nr_free_pages 55583
nr_inactive 133077
nr_active 245476
nr_anon_pages 123307
nr_mapped 18318
nr_file_pages 89063
nr_dirty 39
nr_writeback 0
nr_slab_reclaimable 14452
nr_slab_unreclaimable 10190
nr_page_table_pages 10785
nr_unstable 0
nr_bounce 0
nr_vmscan_write 57271
pgpgin 26968249
pgpgout 40773242
pswpin 0
pswpout 0
pgalloc_dma 307982
pgalloc_dma32 46469184
pgalloc_normal 0
pgalloc_movable 0
pgfree 46832935
pgactivate 6847846
pgdeactivate 6616407
pgfault 37817316
pgmajfault 27426
pgrefill_dma 212390
pgrefill_dma32 18516702
pgrefill_normal 0
pgrefill_movable 0
pgsteal_dma 192152
pgsteal_dma32 13101346
pgsteal_normal 0
pgsteal_movable 0
pgscan_kswapd_dma 217294
pgscan_kswapd_dma32 17699659
pgscan_kswapd_normal 0
pgscan_kswapd_movable 0
pgscan_direct_dma 544
pgscan_direct_dma32 52677
pgscan_direct_normal 0
pgscan_direct_movable 0
pginodesteal 282
slabs_scanned 1252864
kswapd_steal 13267510
kswapd_inodesteal 341476
pageoutrun 211214
allocstall 359
pgrotated 14866

$ slabtop -sc

Active / Total Objects (% used) : 163039 / 210169 (77.6%)
Active / Total Slabs (% used) : 17172 / 17172 (100.0%)
Active / Total Caches (% used) : 102 / 124 (82.3%)
Active / Total Size (% used) : 82070.16K / 90868.73K (90.3%)
Minimum / Average / Maximum Object : 0.08K / 0.43K / 9.66K

OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
21810 21809 99% 1.51K 4362 5 34896K ext3_inode_cache
68310 24144 35% 0.17K 2970 23 11880K buffer_head
14298 14267 99% 0.61K 2383 6 9532K radix_tree_node
24804 24791 99% 0.32K 2067 12 8268K dentry
391 391 100% 9.66K 391 1 6256K task_struct
24106 23844 98% 0.23K 1418 17 5672K vm_area_struct
5750 5277 91% 0.38K 575 10 2300K filp
13494 13478 99% 0.15K 519 26 2076K sysfs_dir_cache
406 349 85% 4.07K 58 7 1856K kmalloc-4096
1125 1120 99% 1.37K 225 5 1800K shmem_inode_cache
780 733 93% 2.07K 52 15 1664K kmalloc-2048
990 983 99% 1.15K 165 6 1320K proc_inode_cache
129 129 100% 4.12K 129 1 1032K names_cache

I would have save I'm already missing quite a few hundred megabytes...

What else would be interesting to see ?

Zdenek