Arena* CallocArenaPool::AllocArena(size_t size) {
Arena* ret = nullptr;
{
std::lock_guard<std::mutex> lock(lock_); // We used to check only the first free arena but we're now checking two. // // FIXME: This is a workaround for `oatdump` running out of memory because of an allocation // pattern where we would allocate a large arena (more than the default size) and then a // normal one (default size) and then return them to the pool together, with the normal one // passed as `first` to `FreeArenaChain()`, thus becoming the first in the `free_arenas_` // list. Since we checked only the first arena, doing this repeatedly would never reuse the // existing freed larger arenas and they would just accumulate in the free arena list until // running out of memory. This workaround allows reusing the second arena in the list, thus // fixing the problem for this specific allocation pattern. Similar allocation patterns // with three or more arenas can still result in out of memory issues. if (free_arenas_ != nullptr && LIKELY(free_arenas_->Size() >= size)) {
ret = free_arenas_;
free_arenas_ = free_arenas_->next_;
} elseif (free_arenas_ != nullptr &&
free_arenas_->next_ != nullptr &&
free_arenas_->next_->Size() >= size) {
ret = free_arenas_->next_;
free_arenas_->next_ = free_arenas_->next_->next_;
}
} if (ret == nullptr) {
ret = new CallocArena(size);
}
ret->Reset(); return ret;
}
void CallocArenaPool::TrimMaps() { // Nop, because there is no way to do madvise here.
}
size_t CallocArenaPool::GetBytesAllocated() const {
size_t total = 0;
std::lock_guard<std::mutex> lock(lock_); for (Arena* arena = free_arenas_; arena != nullptr; arena = arena->next_) {
total += arena->GetBytesAllocated();
} return total;
}
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.9 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.