Пример #1
0
MemoryManager::MemoryManager()
    : m_front(nullptr)
    , m_limit(nullptr)
    , m_sweeping(false) {
#ifdef USE_JEMALLOC
  threadStats(m_allocated, m_deallocated, m_cactive, m_cactiveLimit);
#endif
  resetStatsImpl(true);
  m_stats.maxBytes = std::numeric_limits<int64_t>::max();
  // make the circular-lists empty.
  m_sweep.next = m_sweep.prev = &m_sweep;
  m_strings.next = m_strings.prev = &m_strings;
}
Пример #2
0
void MemoryManager::resetAllocator() {
  assert(m_natives.empty() && m_sweepables.empty());
  // decref apc strings referenced by this request
  DEBUG_ONLY auto nstrings = StringData::sweepAll();

  // cleanup root maps
  dropRootMaps();

  // free the heap
  m_heap.reset();

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

  resetStatsImpl(true);
  FTRACE(1, "reset: strings {}\n", nstrings);
}
Пример #3
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);
  TRACE(1, "reset: apc-arrays %lu strings %u\n", napcs, nstrings);
}
Пример #4
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;
}
Пример #5
0
void MemoryManager::resetAllocator() {
  UNUSED auto napcs = m_apc_arrays.size();
  while (!m_apc_arrays.empty()) {
    auto a = m_apc_arrays.back();
    m_apc_arrays.pop_back();
    a->sweep();
  }
  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: apc-arrays %lu strings %u slabs %lu big %lu\n",
        napcs, nstrings, nslabs, nbig);
}