ResourceMark::~ResourceMark() { if (!enabled) return; # ifdef ASSERT assert(area->nesting> 0, "nesting must be positive"); area->nesting--; # endif if (PrintResourceAllocation) { lprintf("deallocating to mark %#lx\n", top); } ResourceAreaChunk* prevc; ResourceAreaChunk* c; for (c = area->chunk; c != chunk; c = prevc) { // deallocate all chunks behind marked chunk prevc = c->prev; resources.addToFreeList(c); } area->chunk = c; if (c == NULL) { top = NULL; return; } c->freeTo(top); if (top == c->bottom) { // this chunk is completely unused - deallocate it area->chunk = c->prev; resources.addToFreeList(c); } }
bool Resources::contains(char* p) { in_rsrc = false; p_rsrc = p; processes->processesDo(rsrcf2); # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) for (ResourceAreaChunk* c = freeChunks; c; c = c->prev) { if (c->contains(p)) warning("Resources::contains(): p is deallocated!"); } # endif return in_rsrc; }
ResourceAreaChunk* Resources::new_chunk(fint min_capacity, ResourceAreaChunk* previous) { _in_consistent_state = false; ResourceAreaChunk* res = getFromFreeList(min_capacity); if (res) { res->initialize(previous); } else { res = new ResourceAreaChunk(min_capacity, previous); _allocated += res->capacity(); // Subtract the size of the resource chunk from the 'C-Heap' area. TrackCHeapInMonitor::adjust(-res->capacity()); } _in_consistent_state = true; return res; }
ResourceAreaChunk* Resources::new_chunk(int min_capacity, ResourceAreaChunk* previous) { _in_consistent_state = false; ResourceAreaChunk* res = getFromFreeList(min_capacity); if (res) { res->initialize(previous); } else { res = new ResourceAreaChunk(min_capacity, previous); _allocated += res->capacity(); if (PrintResourceChunkAllocation) { std->print("*allocating new resource area chunk of >=%d bytes, new total = %d bytes\n", min_capacity, _allocated); } } _in_consistent_state = true; assert(res, "just checking"); return res; }