• Y
    rcu: reduce more than 7MB heap memory by malloc_trim() · 5a22ab71
    Yang Zhong 提交于
    Since there are some issues in memory alloc/free machenism
    in glibc for little chunk memory, if Qemu frequently
    alloc/free little chunk memory, the glibc doesn't alloc
    little chunk memory from free list of glibc and still
    allocate from OS, which make the heap size bigger and bigger.
    
    This patch introduce malloc_trim(), which will free heap
    memory when there is no rcu call during rcu thread loop.
    malloc_trim() can be enabled/disabled by --enable-malloc-trim/
    --disable-malloc-trim in the Qemu configure command. The
    default malloc_trim() is enabled for libc.
    
    Below are test results from smaps file.
    (1)without patch
    55f0783e1000-55f07992a000 rw-p 00000000 00:00 0  [heap]
    Size:              21796 kB
    Rss:               14260 kB
    Pss:               14260 kB
    
    (2)with patch
    55cc5fadf000-55cc61008000 rw-p 00000000 00:00 0  [heap]
    Size:              21668 kB
    Rss:                6940 kB
    Pss:                6940 kB
    Signed-off-by: NYang Zhong <yang.zhong@intel.com>
    Message-Id: <1513775806-19779-1-git-send-email-yang.zhong@intel.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    5a22ab71
configure 175.5 KB