Pthreads - High memory usage

后端 未结 6 2012
梦谈多话
梦谈多话 2021-02-08 15:42

I am programming something in C that creates a lot of Pthreads in Linux on a 256Mb system. I usually have +200Mb free.

When I run the program with a low amount of thread

6条回答
  •  盖世英雄少女心
    2021-02-08 16:37

    Why stacksize = (double) 16*1024; ? It is integer.

    Try to set it to 32 or 64 kilobytes, because 16*1024 may be not allowed; there can be also TLS in the stack (even you doesn't use TLS; libraries do, including libc).

    So, change the line to

    stacksize = 64*1024; 
    

    and check how much memory is consumed.

提交回复
热议问题