Skip to content

Commit 6605d30

Browse files
committed
reduce the duration of the v8::Locker by limiting its scope only to the critical sections where interaction with v8::HeapStatistics
1 parent d2cefd7 commit 6605d30

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/V8/Utils.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,16 @@ std::string getHeapStatisticsString(v8::HeapStatistics & heap_statistics)
456456

457457
void checkHeapLimit(v8::Isolate * isolate, size_t max_v8_heap_size_in_bytes)
458458
{
459-
v8::Locker locker(isolate);
460-
v8::Isolate::Scope isolate_scope(isolate);
461-
v8::HandleScope handle_scope(isolate);
462-
v8::HandleScope scope(isolate);
463459
v8::HeapStatistics heap_statistics;
464-
isolate->GetHeapStatistics(&heap_statistics);
460+
461+
/// Lock only for getting heap statistics
462+
{
463+
v8::Locker locker(isolate);
464+
v8::Isolate::Scope isolate_scope(isolate);
465+
v8::HandleScope handle_scope(isolate);
466+
v8::HandleScope scope(isolate);
467+
isolate->GetHeapStatistics(&heap_statistics);
468+
}
465469

466470
auto used = heap_statistics.used_heap_size();
467471
auto total = heap_statistics.heap_size_limit();

0 commit comments

Comments
 (0)