This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fopen from within a pthread


On 06/02/2018 06:48 PM, Paul Pluzhnikov via libc-help wrote:
> On Sat, Jun 2, 2018 at 3:31 PM Martin Beynon <mebeyn@gmail.com> wrote:
>>
>> Is this erroneous behaviour, or can this be explained in some way?
> 
> 
> There is nothing erroneous about it.
> 
> What you are observing is the creation of thread-specific arena, from
> which malloc will return memory to the new thread.
> 
> GLIBC uses thread-specific arenas to avoid having to lock malloc
> internal structures when multiple threads allocate and free memory.
> Additional info can be found here:
> https://sourceware.org/glibc/wiki/MallocInternals

Also note that VM size is not the same as RSS.

The new thread arena, usually ~64MiB in size on 64-bit, is only taking
up VM space, but not consuming any real memory (RSS).

Therefore this is just an accounting procedure. Real memory will only
be used as you dirty the pages.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]