Example #1
0
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);
  }
}