pthread_create memory size
Hi all,
I'm using xenomai on kernel 2.6.29 on a powerpc based board.
I see that when I call :
cat proc/meminfo
before pthread_create and after it there is a difference of 2MB in free memory , indicating that the thread is being allocated 2MB of ram (?) .
before :
MemTotal: 256868 kB MemFree: 227624 kB
After :
MemTotal: 256868 kB MemFree: 225632 kB
I am calling pthread_attr_setstacksize(&attr,8192) before calling pthread_create so it shouldn't be the stack size . Is this the expected memory consuption per thread ?
if not, how can I reduce this ?
Thanks ,
Yigal Goldberger.
Quoted 10 lines · Yigal Goldberger
Hi all,
I'm using xenomai on kernel 2.6.29 on a powerpc based board.
I see that when I call :
cat proc/meminfo
beforepthread_createand after it there is a difference of 2MB in free memory , indicating that the thread is being allocated 2MB of ram (?) .before :
MemTotal: 256868 kB MemFree: 227624 kB
Quoted 8 lines
After :
MemTotal: 256868 kB MemFree: 225632 kBI am calling
pthread_attr_setstacksize(&attr,8192)before callingpthread_createso it shouldn't be the stack size . Is this the expected memory consuption per thread ?
if not, how can I reduce this ?
That is explained in the TROUBLESHOOTING guide, use ulimit -s. In fact, I suspect the behaviour depends on the version of the glibc you use. A better indicator of your process memory map is /proc/pid/maps.
Note that a stacksize of 8K is a bit low, such simple functions as printf will cause stack overflows with this stack size.
Signature · 1 line
Gilles
Quoted 15 lines · Gilles Chanteperdrix
Quoted 14 lines · Yigal Goldberger
Hi all,
I'm using xenomai on kernel 2.6.29 on a powerpc based board.
I see that when I call :
cat proc/meminfo
beforepthread_createand after it there is a difference of 2MB in free memory , indicating that the thread is being allocated 2MB of ram (?) .before :
MemTotal: 256868 kB MemFree: 227624 kBAfter :
MemTotal: 256868 kB MemFree: 225632 kB
Quoted 7 lines
Quoted 4 lines
I am calling
pthread_attr_setstacksize(&attr,8192)before callingpthread_createso it shouldn't be the stack size . Is this the expected memory consuption per thread ?
if not, how can I reduce this ?That is explained in the TROUBLESHOOTING guide, use ulimit -s. In fact, I suspect the behaviour depends on the version of the glibc you use.
In particular, if using an old glibc with linuxthreads (that is a really old glibc), the glibc creates an additional thread when creating the first thread. The 2MB you see maybe the stack of this additional thread.
Signature · 1 line
Gilles