when creating a thread, using pthread_create, the memory address space reported (via top and ps) grows significantly per the info below:
The stack size for the thread is explicity set, so that is fine and I can see it pop up in pmap.
But what I cannot explain is the is the 65404 KB hit? Is this a linux kernel mapping or what exactly?
The detachstate attribute is also set for the thread and even though it finished in <1s, the memory mapping is still present in the pmap.
Is this simply part of linux memory management in general, once mapped and then can be resused? Can the 65M hit be tuned, as this is a single thread case and when multiple threads are created simultaneously, then VSZ reporred ramps up very fast. 10 threads, 650M swell in process address space reported.
...shared libs
...shared libs
2adf40000000 (132 KB) rw-p (00:00 0) <--- stack size for the thread.
2adf40021000 (65404 KB) ---p (00:00 0) <--- what is this?
7ffcb8bed000 (128 KB) rwxp (00:00 0) [stack]
7ffcb8c0d000 (4 KB) rw-p (00:00 0)
7ffcb8dc6000 (8 KB) r--p (00:00 0) [vvar]
7ffcb8dc8000 (8 KB) r-xp (00:00 0) [vdso]
ffffffffff600000 (4 KB) r-xp (00:00 0) [vsyscall]
mapped: 116172 KB writable/private: 1140 KB shared: 0 KB
thank you.
EDIT:
So I added a second thread and pmap now shows:
2adf40000000 (132 KB) rw-p (00:00 0)
2adf40021000 (65404 KB) ---p (00:00 0)
2adf44000000 (132 KB) rw-p (00:00 0)
2adf44021000 (65404 KB) ---p (00:00 0)
7ffcb8bed000 (128 KB) rwxp (00:00 0) [stack]
7ffcb8c0d000 (4 KB) rw-p (00:00 0)
7ffcb8dc6000 (8 KB) r--p (00:00 0) [vvar]
7ffcb8dc8000 (8 KB) r-xp (00:00 0) [vdso]
ffffffffff600000 (4 KB) r-xp (00:00 0) [vsyscall]
mapped: 181840 KB writable/private: 1400 KB shared: 0 KB
So now there is 2 stacks and the 65M regions. Both of which has pumped up the Virtual Address space reported also.
EDIT: environment: glibc : ldd (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19 and kernel is 4.4.103