MemMapArena::MemMapArena(size_t size, bool low_4gb, constchar* name)
: map_(Allocate(size, low_4gb, name)) {
memory_ = map_.Begin();
static_assert(ArenaAllocator::kArenaAlignment <= kMinPageSize, "Arena should not need stronger alignment than kMinPageSize.");
DCHECK_ALIGNED(memory_, ArenaAllocator::kArenaAlignment);
size_ = map_.Size();
}
MemMap MemMapArena::Allocate(size_t size, bool low_4gb, constchar* name) { // Round up to a full page as that's the smallest unit of allocation for mmap() // and we want to be able to use all memory that we actually allocate.
size = RoundUp(size, gPageSize);
std::string error_msg; // TODO(b/278665389): remove this retry logic if the root cause is found.
constexpr int MAX_RETRY_CNT = 3; int retry_cnt = 0; while (true) {
MemMap map = MemMap::MapAnonymous(name, size, PROT_READ | PROT_WRITE, low_4gb, &error_msg); if (map.IsValid()) { if (retry_cnt > 0) {
LOG(WARNING) << "Succeed with retry(cnt=" << retry_cnt << ")";
} return map;
} else { if (retry_cnt == MAX_RETRY_CNT) {
CHECK(map.IsValid()) << error_msg << "(retried " << retry_cnt << " times)";
}
}
retry_cnt++;
LOG(ERROR) << error_msg << " but retry(cnt=" << retry_cnt << ")";
}
}
MemMapArena::~MemMapArena() { // Destroys MemMap via std::unique_ptr<>.
}
if (arena_allocator::kArenaAllocatorPreciseTracking) { // Do not reuse arenas when tracking. while (first != nullptr) {
Arena* next = first->next_; delete first;
first = next;
} return;
}
if (first != nullptr) {
Arena* last = first; while (last->next_ != nullptr) {
last = last->next_;
}
std::lock_guard<std::mutex> lock(lock_);
last->next_ = free_arenas_;
free_arenas_ = first;
}
}
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.