| OLD | NEW |
| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // This single GC is not enough for two reasons: | 396 // This single GC is not enough for two reasons: |
| 397 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. | 397 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. |
| 398 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that | 398 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that |
| 399 // some heap allocated objects own objects that contain persistent
handles | 399 // some heap allocated objects own objects that contain persistent
handles |
| 400 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. | 400 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. |
| 401 // | 401 // |
| 402 // Regarding (1), we force a precise GC at the end of the current event
loop. So if you want | 402 // Regarding (1), we force a precise GC at the end of the current event
loop. So if you want |
| 403 // to collect all garbage, you need to wait until the next event loop. | 403 // to collect all garbage, you need to wait until the next event loop. |
| 404 // Regarding (2), it would be OK in practice to trigger only one GC per
gcEpilogue, because | 404 // Regarding (2), it would be OK in practice to trigger only one GC per
gcEpilogue, because |
| 405 // GCController.collectAll() forces 7 V8's GC. | 405 // GCController.collectAll() forces 7 V8's GC. |
| 406 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | 406 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::Forc
edGC); |
| 407 | 407 |
| 408 // Forces a precise GC at the end of the current event loop. | 408 // Forces a precise GC at the end of the current event loop. |
| 409 Heap::setForcePreciseGCForTesting(); | 409 Heap::setForcePreciseGCForTesting(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent",
"usedHeapSizeAfter", usedHeapSize(isolate)); | 412 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent",
"usedHeapSizeAfter", usedHeapSize(isolate)); |
| 413 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); | 413 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void V8GCController::minorGCEpilogue(v8::Isolate* isolate) | 416 void V8GCController::minorGCEpilogue(v8::Isolate* isolate) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 static size_t lastUsageReportedToV8 = 0; | 450 static size_t lastUsageReportedToV8 = 0; |
| 451 | 451 |
| 452 size_t currentUsage = Partitions::currentDOMMemoryUsage(); | 452 size_t currentUsage = Partitions::currentDOMMemoryUsage(); |
| 453 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las
tUsageReportedToV8); | 453 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las
tUsageReportedToV8); |
| 454 isolate->AdjustAmountOfExternalAllocatedMemory(diff); | 454 isolate->AdjustAmountOfExternalAllocatedMemory(diff); |
| 455 | 455 |
| 456 lastUsageReportedToV8 = currentUsage; | 456 lastUsageReportedToV8 = currentUsage; |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace blink | 459 } // namespace blink |
| OLD | NEW |