malloc_state
Arena
아레나는 malloc()에서 메모리 관리 부분을 포함한 Main, thread에 대한 힙 영역이다.
이 구조체는 Arena의 헤더 세부 정보를 나타낸다. 메인 스레드의 영역은 전역 변수이며 힙 세그먼트의 부분이 아니다. 메인 스레드 이외에 아레나의 헤더(malloc_state 구조체)는 각각의 힙 세그먼트에 저장됩니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | struct malloc_state { /* 접근 직렬화 */ __libc_lock_define (, mutex); /* Flags (formerly in max_fast). */ int flags; /* Fastbins */ mfastbinptr fastbinsY[NFASTBINS]; /* 최상위 chunk의 base address -- not otherwise kept in a bin */ mchunkptr top; /* 가장 최근의 작은 요청으로부터 분리된 나머지 */ mchunkptr last_remainder; /* 위에서 설명한대로 pack된 일반적인 bins */ mchunkptr bins[NBINS * 2 - 2]; /* Bitmap of bins */ unsigned int binmap[BINMAPSIZE]; /* 연결리스트 */ struct malloc_state *next; /* free된 아레나들을 위한 연결리스트. Access to this field is serialized by free_list_lock in arena.c. */ struct malloc_state *next_free; /* 이 아래나의 몇개의 스레드가 붙어있는지 아레나가 free list에 있다면 0이다. 이 필드에 대한 액세스는 arena.c의 free_list_lock에 의해 직렬화됩니다. */ INTERNAL_SIZE_T attached_threads; /* 현재 arena의 시스템으로부터 메모리 할당 */ INTERNAL_SIZE_T system_mem; INTERNAL_SIZE_T max_system_mem; }; typedef struct malloc_state *mstate; | cs |
'Heap' 카테고리의 다른 글
06.malloc 분석 (0) | 2018.06.05 |
---|---|
05.Internal functions (0) | 2018.06.01 |
04.Bins and Chunks (0) | 2018.05.24 |
02.malloc_chunk (0) | 2018.05.24 |
01.Understanding glibc malloc (0) | 2018.05.21 |