Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/bindings/core/v8/V8GCController.cpp

Issue 1328653002: Introduce V8GCController::collectAllGarbage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 void V8GCController::collectGarbage(v8::Isolate* isolate) 476 void V8GCController::collectGarbage(v8::Isolate* isolate)
477 { 477 {
478 v8::HandleScope handleScope(isolate); 478 v8::HandleScope handleScope(isolate);
479 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola te), DOMWrapperWorld::create(isolate)); 479 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola te), DOMWrapperWorld::create(isolate));
480 ScriptState::Scope scope(scriptState.get()); 480 ScriptState::Scope scope(scriptState.get());
481 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate); 481 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate);
482 scriptState->disposePerContextData(); 482 scriptState->disposePerContextData();
483 } 483 }
484 484
485 void V8GCController::collectAllGarbage(v8::Isolate* isolate)
486 {
487 for (unsigned i = 0; i < 5; i++)
488 V8GCController::collectGarbage(isolate);
489 }
490
485 void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate) 491 void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate)
486 { 492 {
487 if (!isMainThread()) 493 if (!isMainThread())
488 return; 494 return;
489 495
490 static size_t lastUsageReportedToV8 = 0; 496 static size_t lastUsageReportedToV8 = 0;
491 497
492 size_t currentUsage = WTF::Partitions::currentDOMMemoryUsage(); 498 size_t currentUsage = WTF::Partitions::currentDOMMemoryUsage();
493 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8); 499 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8);
494 isolate->AdjustAmountOfExternalAllocatedMemory(diff); 500 isolate->AdjustAmountOfExternalAllocatedMemory(diff);
(...skipping 23 matching lines...) Expand all
518 Visitor* m_visitor; 524 Visitor* m_visitor;
519 }; 525 };
520 526
521 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) 527 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
522 { 528 {
523 DOMWrapperTracer tracer(visitor); 529 DOMWrapperTracer tracer(visitor);
524 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); 530 v8::V8::VisitHandlesWithClassIds(isolate, &tracer);
525 } 531 }
526 532
527 } // namespace blink 533 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698