KVM ubuntu consumes a lot of RAM

ONE FOTON

Member
Jun 30, 2017
35
0
11
40
Argentina, Cordoba
hi guys!
I hope you had a very happy start to the year!

Straight to the point!
I have a kvm ubuntu machine working very well!
but apparently there is a lack of communication between the host and the vm,
because the consumption of the host is not equal to the consumption in the vm, see captures
vm consumo ram 2018-01-01 21-01-16.png

consumes ram host 2018-01-01 21-04-49.png

I thought about installing balloon service, but according to the wiki in linux, this is not necessary!

Will someone have an idea where the problem will be?

vm.conf
agent: 1
bootdisk: scsi0
cores: 4
cpu: host
ide2: local:iso/ubuntu-gnome-16.04.3-desktop-amd64.iso,media=cdrom,size=1319328K
keyboard: es
memory: 3072
name: PROFITTRAILER
net0: virtio=92:E0:A9:49:DC:F9,bridge=vmbr0
numa: 0
ostype: l26
scsi0: local:105/vm-105-disk-1.qcow2,size=16G
scsihw: virtio-scsi-pci
smbios1: uuid=717aacd8-ffa0-4f5d-b3c7-1966b8850b17
sockets: 1
vga: qxl
 
No lack.. that what you sea is the cached memory, thats linuxlike... ;) To that in the VM and look again:
Code:
sync; echo 1 > /proc/sys/vm/drop_caches
 
Show me screenshot of "htop" please. If not installed, install it with "apt install htop -y"
You can also use "free -m" under Puffer/Cache you see the cached memory of the VM. After the ECHO-Command the cache will be cleard. https://www.linuxatemyram.com/

Cached memory is memory that Linux uses for disk caching. However, this doesn't count as "used" memory, since it will be freed when applications require it. Hence you don't have to worry if a large amount is being used.
 
Once there is no synchronization between what the vm says and what the host shows
Why? It shows right. Mem + Memcache are 2.77GB. That 2.03 is without cache. You need more memory.

Show memoryusage with htop, or execute the following script (better show)
Code:
#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use constant DEFTYPE => 'size';

# pod/help {{{
=head1 NAME

speicherpig - sum up process memory usage based on process names

=head1 SYNOPSIS

speicherpig [--count] [--help] [--byname] [--reverse] [type]

=head1 OPTIONS

    --count     Show count of summed up processes
    --help      Show help and exit
    --byname    Order output by process names, not by sums
    --reverse   Reverse order
                                                                                                                                            
    type        Type of memory usage (passed to ps) to get                                                                                 
                process memory info.  Will use 'size' by                                                                                   
                default.  You may try 'rss'. Use 'vsize' to                                                                                 
                include swap information.                                                                                                   
                                                                                                                                            
                Speicherpig expects size outputs in KiB.                                                                                   
                                                                                                                                            
=head1 AUTHOR                                                                                                                               
                                                                                                                                            
Written by Christoph 'Mehdorn' Weber                                                                                                       

=head1 REPORTING BUGS

Report bugs to <kontakt@das-mehdorn.de>

=head1 COPYRIGHT

Copyright 2010 Christoph 'Mehdorn' Weber.  License Creative Commons
Attribution-Share Alike 3.0 Germany
<http://creativecommons.org/licenses/by-sa/3.0/de/>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY.

=head1 TRIVIA

Speicherpig, speicherpig, does whatever a speicherpig does

=head1 SEE ALSO

ps(1), proc(5)

=cut
# }}}

sub pretty_print {
    my ($kbytes) = @_;

    return sprintf "%7.2f GiB", $kbytes/1024/1024 if $kbytes > 1024*1024;
    return sprintf "%7.2f MiB", $kbytes/1024      if $kbytes > 1024;
    return sprintf "%7.2f KiB", $kbytes;
}

# option/parameter handling {{{
# get options
my $help       = 0;
my $order_name = 0;
my $reverse    = 0;
my $with_count = 0;
GetOptions(
    'byname'  => \$order_name,
    'count'   => \$with_count,
    'help'    => \$help,
    'reverse' => \$reverse,
) or pod2usage(-exitval => 1);
pod2usage(-exitval => 0, -verbose => 2) if $help;

# get the only supported parameter
my ($type) = @ARGV;
$type = 'rss' unless $type;
# }}}

# get process list from ps {{{
open(my $ps, 'ps --no-headers -eo '. $type .',comm |') or
    die 'Cannot run ps: ', $!;
my @proclist = <$ps>;
close($ps) or die 'Cannot close ps: ', $!;
chomp @proclist;
# }}}

# sum up information {{{
my %procsums;
my %proccounts;
foreach my $line (@proclist) {
    my ($size, $name) = $line =~ m{^ *(\d+) (.*)$}og;
    $procsums{$name} += $size;
    $proccounts{$name}++ if $with_count;
}
# }}}

# sort output {{{
my @key_order;
if ($order_name) {
    @key_order = sort keys %procsums;
} else {
    @key_order = sort { $procsums{$a} <=> $procsums{$b} } sort keys %procsums;
}
@key_order = reverse @key_order if $reverse;
# }}}

# show output {{{
foreach my $name (@key_order) {
    # don't show empty sets
    next unless $procsums{$name};

    printf "%16s: %s\n",
        pretty_print($procsums{$name}),
        $with_count ? $name .' ('. $proccounts{$name} .')' : $name
}
# }}}
 
Hi brother !
look at this I mean!
vm windows 10 ram consumption
ram win 10 2018-01-04 15-10-53.png
ram consumption on the proxmox host with balloon controllers

profit-win10 2018-01-04 15-12-16.png
time is exactly the same running the same program in java 8..

:(