That is because the kernel allocated 370MB of memory to the process - once a process gets memory it keeps that memory allocated until the process ends. This is because calls to brk() to allocate memory are very expensive, and brk() would be called to 'give back' the memory as well as to allocate it.
You can try man brk to see if you want to try memory management yourself. However what you see is expected behavior.
yes this is correct.. but i was waiting that using free before calling to pthread_exit all allocated memory was liberated, and is liberated aprox 30 Mb. (allocated by malloc) but not the rest. !?
Yes, i try to put pthread_detach(pthread_self()); before the call pthread_exit() but the result is the same... allways the virtual memory is over 200 Mb.... only is liberated aprox 30 Mb.
In case you misunderstood me I was talking about calling pthread_detach() with the threadid as its argument in the function main() instead of in function cliente().
If calling pthead_self() inside the function main() then its argument would be the calling id of the initial thread instead of each new thread that is created.
the same results....
You can try to execute the code??...
If you do it, you will be able to see as the virtual memory(report) it is reserved and is not liberated when they finish all the threads