0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 23:51:51 +00:00

Re-check memory limit, refs #217

This commit is contained in:
Stefan Siegl 2016-03-26 00:37:53 +01:00
parent 2b4d41abb1
commit 4faab8842c

View File

@ -204,6 +204,16 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
return; return;
} }
if (memory_limit && !c->memory_limit_hit) {
// Re-check memory limit (very short executions might never be hit by timer thread)
v8::HeapStatistics hs;
isolate->GetHeapStatistics(&hs);
if (hs.used_heap_size() > memory_limit) {
c->memory_limit_hit = true;
}
}
if (c->memory_limit_hit) { if (c->memory_limit_hit) {
// Execution has been terminated due to memory limit // Execution has been terminated due to memory limit
sprintf(exception_string, "Script memory limit of %lu bytes exceeded", memory_limit); sprintf(exception_string, "Script memory limit of %lu bytes exceeded", memory_limit);