简体   繁体   中英

posix thread memory consumption

I have a C program creating a detached thread as a child. Inside of the function I pass to pthread_create I use pthread_detach to detach the thread. At the end I call pthread_exit((void *) 0)

I would like to know if it is normal behaviour that the memory consumption increases after the thread is created.

I did a valgrind check and there are no leaks just 4 suppressed errors.

I would like to know if it is normal behaviour that the memory consumption increases after the thread is created.

Yes, as

  1. each thread gets its own stack assigned. The size is OS setting dependend and could be around 1M.

  2. some system resource will be used to manage each thread itself.

Both will be released if the thread ends for a detached thread or if the thread was joined for a joinable thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM