why jemalloc expand virtual memory space so quickly

Jason Evans jasone at canonware.com
Thu Aug 4 00:18:23 PDT 2011


On 08/03/2011 11:52 PM, Ma, Bo wrote:
> It seems that gemalloc costs more virtual memory than glibc_malloc.
>
> We are estimating the possibility that replace glibc_malloc by
> jemalloc.We have seen that jemalloc is really
>
> faster than glibc_malloc and costs less physical memory.But the amount
> of virtual memory increase quickly.
>
> Though we ends our test,it still occupies many virtual memory.
>
> Because we have more physical memory than 4G but we are still using
> 32bit Linux,virtual memory is also badly needed.
>
> Is there any way to reduce the virtual memory cost of jemalloc?

Virtual memory is not of major concern on 64-bit systems, and even on 
32-bit systems, jemalloc typically works fine for applications that 
malloc less than 2 GiB of memory.  In any case, here are some things you 
can do to reduce virtual memory usage:

* Reduce the number of arenas.  If your application is multi-threaded, 
then multiple arenas are utilized.  This can dramatically increase 
virtual memory consumption.

* Reduce the chunk size.  This will increase the odds that chunks can be 
completely unmapped after memory usage decreases.  In practice, whether 
this helps is rather dependent on application allocation patterns, and 
small chunk sizes can degrade throughput.

See the jemalloc man page for details on how to control these and other 
options.

Jason



More information about the jemalloc-discuss mailing list