Exemplo n.º 1
0
void MemoryManager::resetAllocator() {
  UNUSED auto nstrings = StringData::sweepAll();
  UNUSED auto nslabs = m_slabs.size();

  // free smart-malloc slabs
  for (auto slab : m_slabs) {
    free(slab);
  }
  m_slabs.clear();
  resetStatsImpl(true);

  // free large allocation blocks
  UNUSED size_t nbig = 0;
  for (BigNode *n = m_bigs.next, *next; n != &m_bigs; n = next) {
    nbig++;
    next = n->next;
    free(n);
  }
  m_bigs.next = m_bigs.prev = &m_bigs;

  // zero out freelists
  for (auto& i : m_freelists) i.head = nullptr;
  m_front = m_limit = 0;
  if (m_trackingInstances) {
    m_instances = std::unordered_set<void*>();
  }

  resetCouldOOM();
  TRACE(1, "reset: strings %u slabs %lu big %lu\n", nstrings, nslabs, nbig);
}
Exemplo n.º 2
0
void MemoryManager::resetAllocator() {
  // decref apc strings and arrays referenced by this request
  DEBUG_ONLY auto napcs = m_apc_arrays.size();
  while (!m_apc_arrays.empty()) {
    auto a = m_apc_arrays.back();
    m_apc_arrays.pop_back();
    a->sweep();
  }
  DEBUG_ONLY auto nstrings = StringData::sweepAll();

  // free the heap
  m_heap.reset();

  // zero out freelists
  for (auto& i : m_freelists) i.head = nullptr;
  m_front = m_limit = 0;

  resetStatsImpl(true);
  resetCouldOOM();
  TRACE(1, "reset: apc-arrays %lu strings %u\n", napcs, nstrings);
}
Exemplo n.º 3
0
void MemoryManager::resetAllocator() {
  StringData::sweepAll();

  // free smart-malloc slabs
  for (auto slab : m_slabs) {
    free(slab);
  }
  m_slabs.clear();
  resetStatsImpl(true);

  // free large allocation blocks
  for (SweepNode *n = m_sweep.next, *next; n != &m_sweep; n = next) {
    next = n->next;
    free(n);
  }
  m_sweep.next = m_sweep.prev = &m_sweep;

  // zero out freelists
  for (auto& i : m_freelists) i.head = nullptr;
  m_front = m_limit = 0;

  resetCouldOOM();
}