Fixed the OOM but do not throw OOM error

Fixed the OOM but do not throw OOM error

Issue: #IAR8U6
Test: Build & Boot devices

Signed-off-by: huangzhenghua <huangzhenghua3@huawei.com>
Change-Id: Ibe861e996893db670640a7b3c10d89cd165b8488
This commit is contained in:
huangzhenghua 2024-09-13 20:11:08 +08:00
parent c74ac12139
commit 615263c667
2 changed files with 6 additions and 2 deletions

View File

@ -1097,6 +1097,7 @@ void Heap::CollectGarbage(TriggerGCType gcType, GCReason reason)
}
if (shouldThrowOOMError_) {
// Force Full GC after failed Old GC to avoid OOM
LOG_ECMA(INFO) << "Old space is almost OOM, attempt trigger full gc to avoid OOM.";
gcType = TriggerGCType::FULL_GC;
}
oldGCRequested_ = false;

View File

@ -603,9 +603,12 @@ void AppSpawnSpace::IterateOverMarkedObjects(const std::function<void(TaggedObje
uintptr_t LocalSpace::Allocate(size_t size, bool isExpand)
{
auto object = allocator_->Allocate(size);
if (object == 0) {
if (isExpand && Expand()) {
if (object == 0 && isExpand) {
if (Expand()) {
object = allocator_->Allocate(size);
} else {
localHeap_->ThrowOutOfMemoryErrorForDefault(localHeap_->GetJSThread(), size,
" LocalSpace::Allocate", false);
}
}
if (object != 0) {