I was reading source code of glibc. In function void *__libc_malloc(size_t bytes): It shows that if the first thread was created, it calls ptmalloc_init(), and links thread_arena with main_arena, and sets __malloc_initialized to true. On the other hand, the second thread was blocked by the following code in ptmalloc_init(): Thus the thread_arena of the second thread is NULL, and it
Tag: dynamic-memory-allocation
not all malloc’ed memory is “heap” and each block is not contiguous in virtual memory?
It seems that malloc calls mmap internally as : so malloc passes NULL as the first argument for mmap as starting address, so the kernel will choose a suitable virtual address for the mapping, which means malloc will not necessarily create a mapping in the heap area(indicated by brk pointer). If this is true, that means there will be a
Will process’s RES memory drop after memory freed?
I have a process which continuously allocates memory and will free it after another thread have processed related data. When the data processing rate is slow, I see RES memory grows up; but after all the data have been processed, RES goes down but doesn’t go back to original RES value (even after waiting for over 10 minutes). e.g. 10