struct Heap {
/* The mspace to allocate from.
*/
mspace msp;
/* The largest size that this heap is allowed to grow to.
*/
//最多可增长大小
size_t maximumSize;
/* Number of bytes allocated from this mspace for objects,
* including any overhead. This value is NOT exact, and
* should only be used as an input for certain heuristics.
*/
//已经分配出去的大小
size_t bytesAllocated;
/* Number of bytes allocated from this mspace at which a
* concurrent garbage collection will be started.
*/
//并发gc将要启动的时候已经分配的字节数
size_t concurrentStartBytes;
/* Number of objects currently allocated from this mspace.
*/
//当前已被分出去的对象个数
size_t objectsAllocated;
/*
* The lowest address of this heap, inclusive.
*/
char *base;
/*
* The highest address of this heap, exclusive.
*/
char *limit;
/*
* If the heap has an mspace, the current high water mark in
* allocations requested via dvmHeapSourceMorecore.
*/
char *brk;
};
/*
* The live object bitmap.
*/
//所有已经分配的对象,存活的对象
HeapBitmap liveBits;
/*
* The mark bitmap.
*/
//所有可访问的对象
HeapBitmap markBits;
struct HeapBitmap {
/* The bitmap data, which points to an mmap()ed area of zeroed
* anonymous memory.
*/
//看成地址的集合吧
unsigned long *bits;
/* The size of the used memory pointed to by bits, in bytes. This
* value changes when the bitmap is shrunk.
*/
//已用内存大小
size_t bitsLen;
/* The real size of the memory pointed to by bits. This is the
* number of bytes we requested from the allocator and does not
* change.
*/
//大小不会发生改变
size_t allocLen;
/* The base address, which corresponds to the first bit in
* the bitmap.
*/
//基地址
uintptr_t base;
/* The highest pointer value ever returned by an allocation
* from this heap. I.e., the highest address that may correspond
* to a set bit. If there are no bits set, (max < base).
*/
//曾经达到的最高地址
uintptr_t max;
};