ソースを参照

Re-check memory limit, refs #217

Stefan Siegl 9 年 前
コミット
4faab8842c
1 ファイル変更10 行追加0 行削除
  1. 10 0
      v8js_v8.cc

+ 10 - 0
v8js_v8.cc

@@ -204,6 +204,16 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
 		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) {
 		// Execution has been terminated due to memory limit
 		sprintf(exception_string, "Script memory limit of %lu bytes exceeded", memory_limit);