summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-09-10 18:21:20 +0200
committerAnna Henningsen <anna@addaleax.net>2016-09-29 09:46:42 +0200
commit72c60e892c6f5ca309e20953e032a590be7787db (patch)
tree05d996c1be5fe6efd1b51580a34709263bb86ee8 /src/util.cc
parentea94086ad2b53268b5cb870f9ba5a1f84741fa41 (diff)
downloadandroid-node-v8-72c60e892c6f5ca309e20953e032a590be7787db.tar.gz
android-node-v8-72c60e892c6f5ca309e20953e032a590be7787db.tar.bz2
android-node-v8-72c60e892c6f5ca309e20953e032a590be7787db.zip
src: notify V8 for low memory when alloc fails
Call `v8::Isolate::GetCurrent()->LowMemoryNotification()` when an allocation fails to give V8 a chance to clean up and return memory before retrying (and possibly giving up). PR-URL: https://github.com/nodejs/node/pull/8482 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 14aa68996f..9fb5c3fd28 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -77,4 +77,13 @@ BufferValue::BufferValue(Isolate* isolate, Local<Value> value) {
}
}
+void LowMemoryNotification() {
+ if (v8_initialized) {
+ auto isolate = v8::Isolate::GetCurrent();
+ if (isolate != nullptr) {
+ isolate->LowMemoryNotification();
+ }
+ }
+}
+
} // namespace node