Chromium Code Reviews| Index: Source/bindings/v8/V8GCController.cpp |
| diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp |
| index dfea224c4ef72765891958d54bef73313bc0727d..4c471ae0f99fdafe9819a0fab9b2554c02592c7d 100644 |
| --- a/Source/bindings/v8/V8GCController.cpp |
| +++ b/Source/bindings/v8/V8GCController.cpp |
| @@ -48,6 +48,7 @@ |
| #include "core/html/imports/HTMLImportsController.h" |
| #include "core/inspector/InspectorTraceEvents.h" |
| #include "core/svg/SVGElement.h" |
| +#include "platform/Partitions.h" |
| #include "platform/TraceEvent.h" |
| #include <algorithm> |
| @@ -437,4 +438,18 @@ void V8GCController::collectGarbage(v8::Isolate* isolate) |
| scriptState->disposePerContextData(); |
| } |
| +void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate) |
| +{ |
| + if (!isMainThread()) |
| + return; |
| + |
| + static size_t lastUsageReportedToV8 = 0; |
| + |
| + size_t currentUsage = Partitions::currentDOMMemoryUsage(); |
| + ssize_t diff = static_cast<ssize_t>(currentUsage) - static_cast<ssize_t>(lastUsageReportedToV8); |
| + isolate->AdjustAmountOfExternalAllocatedMemory(diff); |
|
Tom Sepez
2014/06/05 17:58:08
nit: down the road, you'd probably be happier with
|
| + |
| + lastUsageReportedToV8 = currentUsage; |
| +} |
| + |
| } // namespace WebCore |