News for hackers. Stuff that matters.
Re:Scalable memory allocation using jemalloc (2011) by rayiner on Saturday November 15, 2014 @12:25PM (#8612107)
Yes (to both--new usually calls malloc), but the degree to which depends on the platform. In the old days, there was a single lock around the allocator serializing malloc/free. These days, all the major platforms have a memory allocator that tolerates some degree of concurrency, and you can also link in tcmalloc or jemalloc. Even then, a lot will depend on your allocation patterns. For example, many threaded malloc implementations depend on thread-local caches to avoid having to take a lock on the fast path. This works great for many workloads, but can also fall flat on others. Consider what happens when a producer thread allocates memory, passes a pointer to a consumer thread which frees it. The thread-local cache in the producer thread will never be replenished by free() calls, and the thread-local cache in the consumer thread will never be used by malloc() calls. Thus performance can become very dependent on the mechanism the allocator uses to transfer memory to/from the local caches and the global heap.

There are no comments on this comment yet.