diff options
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index a3d446c2a5..51adb81692 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -253,7 +253,15 @@ T* UncheckedRealloc(T* pointer, size_t n) { return nullptr; } - return static_cast<T*>(realloc(pointer, full_size)); + void* allocated = realloc(pointer, full_size); + + if (UNLIKELY(allocated == nullptr)) { + // Tell V8 that memory is low and retry. + LowMemoryNotification(); + allocated = realloc(pointer, full_size); + } + + return static_cast<T*>(allocated); } // As per spec realloc behaves like malloc if passed nullptr. |