In glibc, malloc is implemented with arenas. So, for example, it is possible that the memory first allocated by malloc and later freed in thread A can not be used by another call of malloc in thread B, since thread A and B may be in different arenas, and different arenas maintain different heaps and free lists of memory.
When it comes to C++ (maybe also C++11 since C++11 has a new standard), is the story still the same?
Or different threads actually share the same segment of heap and free list of memory, and new in one thread can allocate the memory first newed and later deleted by other thread?
Aucun commentaire:
Enregistrer un commentaire