Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#55532 - [glibc] Malloc's new per thread cache is not returned when thread exits

Attached to Project: Arch Linux
Opened by Hal Gentz (zegentz) - Wednesday, 06 September 2017, 07:07 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Monday, 09 October 2017, 09:23 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No


glibc 2.26 enables a new per-thread cache to malloc. This cache consumes around 1.23 kB of memory per thread created.

This cache however is not released when the thread exits. This cache can't be detected with malloc_heap() and many/most memory profiling tools (memcheck, massif, heapcheck, etc) either.

For applications which create and remove lots of threads, this can quickly consume gigabytes of memory, while the source of the consumption appears to be unknown.

This issue was originally reported in 2010 at and

Additional info:
Happens in: glibc 2.26-1 and glibc 2.26-2

Steps to reproduce:
1) Compile attached file.
2) Run it and wait for ~25 seconds
3) Look at VmRSS of ~127300 kB
This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Monday, 09 October 2017, 09:23 GMT
Reason for closing:  Fixed
Additional comments about closing:  glibc 2.26-5
Comment by Adrian Petrescu (apetresc) - Thursday, 07 September 2017, 16:43 GMT
Legitimate question: if this bug is related to a new per-thread cache enabled in glibc 2.26, how was the bug originally reported in 2010?
Comment by loqs (loqs) - Thursday, 07 September 2017, 19:05 GMT
Have you reported the issue upstream at ?
Comment by Hal Gentz (zegentz) - Thursday, 07 September 2017, 22:13 GMT
Adrian Petrescu (apetresc): It was made in in 2010 and was disabled by default (being experimental). In glibc 2.26 it was changed to being enabled by default. It can now be disabled using the "--disable-experimental-malloc" (build?) flag.
Comment by Hal Gentz (zegentz) - Thursday, 07 September 2017, 22:27 GMT Comment by A. S. (TheDaemoness) - Saturday, 09 September 2017, 17:54 GMT
glibc 2.26 has just landed in the main repositories, and this bug still appears to be present. Preloading a different malloc implementation (i.e. jemalloc) suppresses the issue, but IMHO that should not be necessary.