From 93d84f28d6e5568139fe7180dd727f710d396d47 Mon Sep 17 00:00:00 2001 From: Bill Budge Date: Fri, 4 Aug 2017 20:28:52 +0000 Subject: [PATCH] Revert "[Memory] Experiment to try using regular version of 'new T[]'." This reverts commit bec2b4d26781674704f9ea7a124a2625e3777e24. Reason for revert: NewArrayOOM fails. Original change's description: > [Memory] Experiment to try using regular version of 'new T[]'. > > - Use normal new, vs. nothrow new. > - Modify NewArray to have only 1 invocation of new. > > Bug: chromium:752056 > Change-Id: I1a2fb3626264b1bf647af9227d55e9b54e44e8b6 > Reviewed-on: https://chromium-review.googlesource.com/600895 > Reviewed-by: Michael Lippautz > Commit-Queue: Bill Budge > Cr-Commit-Position: refs/heads/master@{#47173} TBR=bbudge@chromium.org,mlippautz@chromium.org Change-Id: I881f3b75209714d11d93fae6268171ffa9cc47a1 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:752056 Reviewed-on: https://chromium-review.googlesource.com/602847 Reviewed-by: Bill Budge Commit-Queue: Bill Budge Cr-Commit-Position: refs/heads/master@{#47174} --- src/allocation.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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