Linux kernel 2.6.34
Linux内核2.6.34
In multi-threads program,when each thread uses malloc()
at the same time,an application performance get down.That's because each thread is locked exclusively in malloc()
.
在多线程程序中,当每个线程同时使用malloc()时,应用程序性能会下降。这是因为每个线程都只在malloc()中被锁定。
To avoid this problem,I'm thinking that mallopt()
can be used.
为了避免这个问题,我认为可以使用mallopt()。
For this collision,
对于这次碰撞,
Usage of mallopt()
like below is correct?
使用mallopt()如下所示是正确的吗?
mallopt(M_ARENA_MAX,8);
Also,what is default arena max size?
另外,什么是默认竞技场最大尺寸?
1 个解决方案
#1
1
Look into using gperftools, which has a multi-threaded malloc (tcmalloc).
看看使用gperftools,它有一个多线程malloc(tcmalloc)。
It gives each thread a small thread-local cache for allocating small (<32k) objects from.
它为每个线程提供了一个小的线程局部缓存,用于分配小的(<32k)对象。
#1
1
Look into using gperftools, which has a multi-threaded malloc (tcmalloc).
看看使用gperftools,它有一个多线程malloc(tcmalloc)。
It gives each thread a small thread-local cache for allocating small (<32k) objects from.
它为每个线程提供了一个小的线程局部缓存,用于分配小的(<32k)对象。