Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


KVM taking more and more memory
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

KVM taking more and more memory

komokomo Member
edited December 2012 in General

I have a dedicated server with 4GB RAM running on Debian Squeeze. I created a KVM with 3GB RAM (also running Debian Squeeze) on this server. Debian in KVM is always using between 300 and 500MB RAM.

KVM process takes around 2GB when I start it but it rises continuously. After 3 weeks uptime KVM already takes 3.2GB RAM. What could be a reason for this? Can I do something to keep memory usage on a constant level?

Comments

  • It's cached ram >_>

    Thanked by 1ret
  • kbeeziekbeezie Member
    edited December 2012

    What everyone else said, if you do a free -m output you'll notice a chunk is typically "cached" or "inactive" etc.

    As I've said before: "Free Ram is Wasted Ram"

    If it's not cache/inactive/etc then look at your ps or top output, sort by memory and see what's using it.

    Edit for example my top screen has a memory line:
    Mem: 513M Active, 1966M Inact, 233M Wired, 30M Cache, 63M Buf, 1205M Free

    Only 513MB+233MB is actively being used, the rest (1966MB+30MB+63MB+1205MB) are free to be used if a process needs it.

  • This sounds like a case of cached memory like others said, but to be sure can you log into your KVM VPS via SSH, and run this command:

    free -m

    Go ahead and post the result just to be sure. If it is memory being cached you have nothing to worry about.

  • Host:
    total used free shared buffers cached Mem: 3954 3903 51 0 151 517 -/+ buffers/cache: 3233 721 Swap: 4471 249 4221

    Guest (KVM):
    total used free shared buffers cached Mem: 3022 2184 838 0 340 1223 -/+ buffers/cache: 619 2402 Swap: 1900 0 1900

    Guest is using at the moment a little bit more memory than usual because I have backup running.

    I have a few small other processes running on host but they don't take more than 100MB memory.

  • top:
    Mem: 4049172k total, 3960972k used, 88200k free, 151556k buffers

  • Nobody?

  • @komo said: Nobody?

    Well what does your ps aux or top output say? Probably would help to identify which processes are actually using the memory.

  • Hey you can use that python script ps_mem.py

    http://www.pixelbeat.org/scripts/ps_mem.py

  • @24khost said: Hey you can use that python script ps_mem.py

    http://www.pixelbeat.org/scripts/ps_mem.py

    That's kind of nifty (though I had to mount linprocfs from /compat/linux/proc in order to get it to work on freebsd).

  • well I rebooted KVM guest and it takes currently takes 2.2GB RAM:

    # top -b -n 1 | grep -E 'PID|libvirt' PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1470 libvirt- 20 0 3338m 2.2g 1288 S 4 57.9 9733:13 kvm 1425 root 20 0 204m 1392 1164 S 0 0.0 0:00.06 libvirtd

    2.2GB? is that something common although all processes in the guest system do not use more than 600MB at the moment?

  • # python ps_mem.py | grep kvm 2.2 GiB + 260.0 KiB = 2.2 GiB kvm

  • kbeeziekbeezie Member
    edited December 2012

    @komo said: 2.2GB? is that something common although all processes in the guest system do not use more than 600MB at the moment?

    You try going INTO the kvm guest and then doing a top/ps/etc in there to see what's taking the ram? (and more than likely those are reserves, since we're not talking OpenVz)

    Showing what KVM takes from the outside isn't going to be much help.

  • free -m from guest:
    total used free shared buffers cached Mem: 3022 2204 817 0 341 1240 -/+ buffers/cache: 622 2399 Swap: 1900 0 1900

    i see here 622MB used. 2204 with cache etc.

    are these 2204MB actually 2.2GB from the host? if yes, if I limit KVM ram to 768MB whole kvm process should not take k much more?

  • did you try that ps_mem.py and ps aux ?

    The correct course of action is to figure out what is using the memory and to remedy that. Not just limit the guest (which may result in just getting out of memory errors if you didn't correct the process using the memory).

  • It might be worth showing us one of the domains libvirt config files to see how it's being managed.

  • what do other processes have to do with kvm process?

  • config file

    <domain type='kvm'> <name>kvm</name> <uuid>.....uuid....</uuid> <memory>3145728</memory> <currentMemory>3145728</currentMemory> <vcpu>3</vcpu> <os> <type arch='x86_64' machine='pc-0.12'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <cpu match='exact'> <model>core2duo</model> <vendor>Intel</vendor> <feature policy='require' name='pbe'/> <feature policy='require' name='tm2'/> <feature policy='require' name='est'/> <feature policy='require' name='ss'/> <feature policy='require' name='ht'/> <feature policy='require' name='ds'/> <feature policy='require' name='lahf_lm'/> <feature policy='require' name='tm'/> <feature policy='require' name='cx16'/> <feature policy='require' name='vmx'/> <feature policy='require' name='ds_cpl'/> <feature policy='require' name='xtpr'/> <feature policy='require' name='acpi'/> </cpu> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/vm/vm1.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' unit='0'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='54:52:00:34:46:1b'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> </domain>

  • Take a look at the driver element (cache attribute) here http://libvirt.org/formatdomain.html#elementsDisks

    It may be the I/O caching that's causing the memory usage

  • @soluslabs - we have built libvirt 1.0 packages for CentOS 6, and we have also enabled Xen support. We are also providing Xen 4.2 packages along with kernel-xen 3.6.7. Just putting it out there in case you guys want to test them with SolusVM.

    You can get them here: http://repo.vpsnodebox.com

    By the way, thank you for the awesome support in regards to my own KVM issue. You guys have been extremely responsive, and I really appreciate it :-)

  • @marcm said: @soluslabs - we have built libvirt 1.0 packages for CentOS 6, and we have also enabled Xen support. We are also providing Xen 4.2 packages along with kernel-xen 3.6.7. Just putting it out there in case you guys want to test them with SolusVM.

    You can get them here: http://repo.vpsnodebox.com

    By the way, thank you for the awesome support in regards to my own KVM issue. You guys have been extremely responsive, and I really appreciate it :-)

    Yeah i saw that. I will check it out :)

Sign In or Register to comment.