c++ - pthread_attr_setstacksize and pthread_exit -


About 64 MB RAM is a question about C compatibility programming in embedded systems, especially I I want to reduce the default memory used by the thread, so I have defined:

  pthread_attr_t attr_test; Size_t stackxis = 0x186A0; // 100Kbyte pthread_attr_init (& attr_test); Pthread_attr_setdetachstate (and ent_astest, PTHREAD_CREATE_DETACHED); Pthread_attr_setstacksize (and entre_stest, staxes);  

Therefore, when the thread starts, it uses only 100Kbyte virtual memory but when the thread ends and pthread_exit calls, the virtual memory used by the process increases rapidly

Why? What should I do?

Thank you!

UPDATE :

thread ->

  Zero * thread_test (zero * arg1) {int * param; Param = (int *) arg1; Printf ("Thread% d start \ n", * absolute); Pthread_cond_wait (& amp; condition [* absolute], & amp; mutex [* ultimate]); Printf ("Thread% d stop \ n", * absolute); Pthread_exit (0); }   

MAX_THREADS]; Intra para [MAX_THREADS]; Int Pointer; Int i, keb; Zero * stkaddr; Size_t stacks; ("!!! !!! !!! !!!"); Printf ("Process ID% d \ n \ n", getpid ()); For (i = 0; i

There is a known problem with the add-on or separate thread, manually Cited:

Only when a closed thread is added, it has its previous resources returned to the system.

You can make threads detachable:

  pthread_attr_setdetachstate (3)  

Comments