Boblishus
Boblishus

Reputation: 97

In multi-threads program,malloc() is locked exclusively

Linux kernel 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().

To avoid this problem,I'm thinking that mallopt() can be used.

For this collision,

Usage of mallopt() like below is correct?

mallopt(M_ARENA_MAX,8);

Also,what is default arena max size?

Upvotes: 0

Views: 137

Answers (1)

Michael
Michael

Reputation: 968

Look into using gperftools, which has a multi-threaded malloc (tcmalloc).

It gives each thread a small thread-local cache for allocating small (<32k) objects from.

Upvotes: 1

Related Questions