diff --git a/src/allocation.h b/src/allocation.h index e2e16df11a..e0e147bb7c 100644 --- a/src/allocation.h +++ b/src/allocation.h @@ -34,13 +34,13 @@ class V8_EXPORT_PRIVATE Malloced { template T* NewArray(size_t size) { - int retries = 0; - while (true) { - T* result = new T[size]; - if (result != nullptr) return result; - if (retries++ == 1) FatalProcessOutOfMemory("NewArray"); + T* result = new (std::nothrow) T[size]; + if (result == nullptr) { V8::GetCurrentPlatform()->OnCriticalMemoryPressure(); + result = new (std::nothrow) T[size]; + if (result == nullptr) FatalProcessOutOfMemory("NewArray"); } + return result; } template