OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/workers/WorkerThread.h" | 44 #include "core/workers/WorkerThread.h" |
45 #include "modules/webaudio/AudioNode.h" | 45 #include "modules/webaudio/AudioNode.h" |
46 #include "platform/Timer.h" | 46 #include "platform/Timer.h" |
47 #include "public/web/WebDocument.h" | 47 #include "public/web/WebDocument.h" |
48 #include "public/web/WebLocalFrame.h" | 48 #include "public/web/WebLocalFrame.h" |
49 | 49 |
50 namespace blink { | 50 namespace blink { |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 // FIXME: Oilpan: It may take multiple GC to collect on-heap objects referenced
from off-heap objects. | |
55 // Please see comment in Heap::collectAllGarbage() | |
56 static const int kNumberOfGCsToClaimChains = 5; | |
57 | |
58 class WebLeakDetectorImpl final : public WebLeakDetector { | 54 class WebLeakDetectorImpl final : public WebLeakDetector { |
59 WTF_MAKE_NONCOPYABLE(WebLeakDetectorImpl); | 55 WTF_MAKE_NONCOPYABLE(WebLeakDetectorImpl); |
60 public: | 56 public: |
61 explicit WebLeakDetectorImpl(WebLeakDetectorClient* client) | 57 explicit WebLeakDetectorImpl(WebLeakDetectorClient* client) |
62 : m_client(client) | 58 : m_client(client) |
63 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) | 59 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) |
64 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) | 60 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) |
65 , m_numberOfGCNeeded(0) | 61 , m_numberOfGCNeeded(0) |
66 { | 62 { |
67 ASSERT(m_client); | 63 ASSERT(m_client); |
(...skipping 29 matching lines...) Expand all Loading... |
97 memoryCache()->evictResources(); | 93 memoryCache()->evictResources(); |
98 | 94 |
99 { | 95 { |
100 RefPtrWillBeRawPtr<Document> document = PassRefPtrWillBeRawPtr<Document>
(frame->document()); | 96 RefPtrWillBeRawPtr<Document> document = PassRefPtrWillBeRawPtr<Document>
(frame->document()); |
101 if (ResourceFetcher* fetcher = document->fetcher()) | 97 if (ResourceFetcher* fetcher = document->fetcher()) |
102 fetcher->garbageCollectDocumentResources(); | 98 fetcher->garbageCollectDocumentResources(); |
103 } | 99 } |
104 | 100 |
105 // FIXME: HTML5 Notification should be closed because notification affects t
he result of number of DOM objects. | 101 // FIXME: HTML5 Notification should be closed because notification affects t
he result of number of DOM objects. |
106 | 102 |
107 for (int i = 0; i < kNumberOfGCsToClaimChains; ++i) | 103 V8GCController::collectAllGarbage(isolate); |
108 V8GCController::collectGarbage(isolate); | |
109 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 104 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
110 | 105 |
111 // Task queue may contain delayed object destruction tasks. | 106 // Task queue may contain delayed object destruction tasks. |
112 // This method is called from navigation hook inside FrameLoader, | 107 // This method is called from navigation hook inside FrameLoader, |
113 // so previous document is still held by the loader until the next event loo
p. | 108 // so previous document is still held by the loader until the next event loo
p. |
114 // Complete all pending tasks before proceeding to gc. | 109 // Complete all pending tasks before proceeding to gc. |
115 m_numberOfGCNeeded = 2; | 110 m_numberOfGCNeeded = 2; |
116 m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE); | 111 m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE); |
117 } | 112 } |
118 | 113 |
119 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) | 114 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) |
120 { | 115 { |
121 // We do a second and third GC here to address flakiness | 116 // We do a second and third GC here to address flakiness |
122 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. | 117 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. |
123 // The third GC is necessary for cleaning up Document after worker object di
ed. | 118 // The third GC is necessary for cleaning up Document after worker object di
ed. |
124 | 119 |
125 for (int i = 0; i < kNumberOfGCsToClaimChains; ++i) | 120 V8GCController::collectAllGarbage(V8PerIsolateData::mainThreadIsolate()); |
126 V8GCController::collectGarbage(V8PerIsolateData::mainThreadIsolate()); | |
127 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 121 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
128 | 122 |
129 // Inspect counters on the next event loop. | 123 // Inspect counters on the next event loop. |
130 if (--m_numberOfGCNeeded) | 124 if (--m_numberOfGCNeeded) |
131 m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE); | 125 m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE); |
132 else | 126 else |
133 m_delayedReportTimer.startOneShot(0, FROM_HERE); | 127 m_delayedReportTimer.startOneShot(0, FROM_HERE); |
134 } | 128 } |
135 | 129 |
136 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) | 130 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) |
(...skipping 19 matching lines...) Expand all Loading... |
156 } | 150 } |
157 | 151 |
158 } // namespace | 152 } // namespace |
159 | 153 |
160 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) | 154 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) |
161 { | 155 { |
162 return new WebLeakDetectorImpl(client); | 156 return new WebLeakDetectorImpl(client); |
163 } | 157 } |
164 | 158 |
165 } // namespace blink | 159 } // namespace blink |
OLD | NEW |