Index: third_party/WebKit/Source/platform/heap/ThreadState.cpp |
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
index 53497e71765aa20f04d9c4cb0688c20de2592bc1..2627bc0dee768a66fdfb450e14ef396ffadc59fd 100644 |
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
@@ -334,7 +334,10 @@ void ThreadState::cleanupMainThread() { |
#if defined(LEAK_SANITIZER) |
// See comment below, clear out most garbage before releasing static |
// persistents should some of the finalizers depend on touching |
- // these persistents. |
+ // these persistents. The clearing done includes the static persistents, |
+ // so as to make objects retained by these singletons also be eligible |
+ // for garbage collection right away. |
+ clearStaticPersistentNodes(); |
haraken
2017/01/02 09:26:44
Hmm, I'm not quite sure if this helps.
In my unde
sof
2017/01/02 09:37:16
Hmm, that doesn't make a lot of sense, given the t
|
collectAllGarbage(); |
#endif |
@@ -1500,6 +1503,18 @@ void ThreadState::registerStaticPersistentNode( |
m_staticPersistents.add(node, callback); |
} |
+#if defined(LEAK_SANITIZER) |
+void ThreadState::clearStaticPersistentNodes() { |
+ HashMap<PersistentNode*, ThreadState::PersistentClearCallback> |
+ staticPersistents; |
+ staticPersistents.swap(m_staticPersistents); |
+ |
+ PersistentRegion* persistentRegion = getPersistentRegion(); |
+ for (const auto& it : staticPersistents) |
+ persistentRegion->clearPersistentNode(it.key, it.value); |
+} |
+#endif |
+ |
void ThreadState::releaseStaticPersistentNodes() { |
HashMap<PersistentNode*, ThreadState::PersistentClearCallback> |
staticPersistents; |