Changeset 50562 in webkit


Ignore:
Timestamp:
Nov 5, 2009 7:36:14 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-05 Anton Muhin <antonm@chromium.org>

Reviewed by Adam Barth.

If high memory usage is detected, hint to V8 that it might be due
to external objects retained by V8 objects.
https://bugs.webkit.org/show_bug.cgi?id=31051

  • bindings/v8/V8GCController.cpp: (WebCore::GetMemoryUsageInMB): (WebCore::V8GCController::gcEpilogue): (WebCore::V8GCController::checkMemoryUsage):
  • bindings/v8/V8GCController.h:
  • bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::evaluate): (WebCore::V8Proxy::runScript): (WebCore::V8Proxy::callFunction):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50561 r50562  
     12009-11-05  Anton Muhin  <antonm@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        If high memory usage is detected, hint to V8 that it might be due
     6        to external objects retained by V8 objects.
     7        https://bugs.webkit.org/show_bug.cgi?id=31051
     8
     9        * bindings/v8/V8GCController.cpp:
     10        (WebCore::GetMemoryUsageInMB):
     11        (WebCore::V8GCController::gcEpilogue):
     12        (WebCore::V8GCController::checkMemoryUsage):
     13        * bindings/v8/V8GCController.h:
     14        * bindings/v8/V8Proxy.cpp:
     15        (WebCore::V8Proxy::evaluate):
     16        (WebCore::V8Proxy::runScript):
     17        (WebCore::V8Proxy::callFunction):
     18
    1192009-11-05  Jeff Schiller  <codedread@gmail.com>
    220
  • trunk/WebCore/bindings/v8/V8GCController.cpp

    r50293 r50562  
    417417};
    418418
     419int V8GCController::workingSetEstimateMB = 0;
     420
     421namespace {
     422
     423int getMemoryUsageInMB()
     424{
     425    return ChromiumBridge::memoryUsageMB();
     426}
     427
     428}  // anonymous namespace
     429
    419430void V8GCController::gcEpilogue()
    420431{
     
    426437    visitActiveDOMObjectsInCurrentThread(&epilogueVisitor);
    427438
     439    workingSetEstimateMB = getMemoryUsageInMB();
     440
    428441#ifndef NDEBUG
    429442    // Check all survivals are weak.
     
    439452}
    440453
     454void V8GCController::checkMemoryUsage()
     455{
     456    const int lowUsageMB = 256;  // If memory usage is below this threshold, do not bother forcing GC.
     457    const int highUsageMB = 1024;  // If memory usage is above this threshold, force GC more aggresively.
     458    const int highUsageDeltaMB = 128;  // Delta of memory usage growth (vs. last workingSetEstimateMB) to force GC when memory usage is high.
     459
     460    int memoryUsageMB = getMemoryUsageInMB();
     461    if ((memoryUsageMB > lowUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB))
     462        v8::V8::LowMemoryNotification();
     463}
     464
     465
    441466}  // namespace WebCore
  • trunk/WebCore/bindings/v8/V8GCController.h

    r46239 r50562  
    7979        static void gcPrologue();
    8080        static void gcEpilogue();
     81
     82        static void checkMemoryUsage();
     83
     84    private:
     85        // Estimate of current working set.
     86        static int workingSetEstimateMB;
    8187    };
    8288
  • trunk/WebCore/bindings/v8/V8Proxy.cpp

    r50523 r50562  
    375375    ASSERT(v8::Context::InContext());
    376376
     377    V8GCController::checkMemoryUsage();
     378
    377379#if ENABLE(INSPECTOR)
    378380    if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
     
    419421        return notHandledByInterceptor();
    420422
     423    V8GCController::checkMemoryUsage();
    421424    // Compute the source string and prevent against infinite recursion.
    422425    if (m_recursion >= kMaxRecursionDepth) {
     
    473476v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
    474477{
     478    V8GCController::checkMemoryUsage();
    475479    v8::Local<v8::Value> result;
    476480    {
Note: See TracChangeset for help on using the changeset viewer.