Changeset 91384 in webkit
- Timestamp:
- Jul 20, 2011 11:45:47 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91383 r91384 1 2011-07-20 Scott Graham <scottmg@chromium.org> 2 3 Reviewed by Antti Koivisto. 4 5 REGRESSION (r39725?): Resources removed from document can not be freed 6 until the document is deleted 7 https://bugs.webkit.org/show_bug.cgi?id=61006 8 9 Upon completing a load start a Timer to iterate through 10 CachedResourceLoader's m_documentResources map to check for any items 11 that have only one reference (thus being the reference in the map 12 itself). The map should really be weak, but because the 13 CachedResourceHandle achieves bookkeeping work in addition to 14 reference counting, this is a simpler and more localized way to free 15 the used memory while maintaining the other behaviour (when 16 CachedResource is used as proxy). 17 18 No new layout tests, but with this patch the testcase at 19 https://bugs.webkit.org/attachment.cgi?id=93850 should no longer 20 consume 400MB of ram on load. 21 22 * loader/cache/CachedResource.h: 23 (WebCore::CachedResource::getHandleCount): 24 * loader/cache/CachedResourceLoader.cpp: 25 (WebCore::CachedResourceLoader::loadDone): 26 (WebCore::CachedResourceLoader::garbageCollectDocumentResources): 27 * loader/cache/CachedResourceLoader.h: 28 1 29 2011-07-20 James Robinson <jamesr@chromium.org> 2 30 -
trunk/Source/WebCore/loader/cache/CachedResource.h
r88391 r91384 183 183 184 184 bool canDelete() const { return !hasClients() && !m_request && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; } 185 bool hasOneHandle() const { return m_handleCount == 1; } 185 186 186 187 bool isExpired() const; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r90164 r91384 87 87 : m_document(document) 88 88 , m_requestCount(0) 89 , m_garbageCollectDocumentResourcesTimer(this, &CachedResourceLoader::garbageCollectDocumentResourcesTimerFired) 89 90 , m_autoLoadImages(true) 90 91 , m_loadFinishing(false) … … 562 563 frame()->loader()->loadDone(); 563 564 performPostLoadActions(); 565 566 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 567 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 568 } 569 570 // Garbage collecting m_documentResources is a workaround for the 571 // CachedResourceHandles on the RHS being strong references. Ideally this 572 // would be a weak map, however CachedResourceHandles perform additional 573 // bookkeeping on CachedResources, so instead pseudo-GC them -- when the 574 // reference count reaches 1, m_documentResources is the only reference, so 575 // remove it from the map. 576 void CachedResourceLoader::garbageCollectDocumentResourcesTimerFired(Timer<CachedResourceLoader>* timer) 577 { 578 Vector<String, 10> toDelete; 579 580 for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m_documentResources.end(); ++it) { 581 if (it->second->hasOneHandle()) 582 toDelete.append(it->first); 583 } 584 585 for (Vector<String, 10>::const_iterator idel = toDelete.begin(); idel != toDelete.end(); ++idel) 586 m_documentResources.remove(*idel); 564 587 } 565 588 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r89503 r91384 31 31 #include "CachePolicy.h" 32 32 #include "ResourceLoadPriority.h" 33 #include "Timer.h" 33 34 #include <wtf/Deque.h> 34 35 #include <wtf/HashMap.h> … … 118 119 bool canRequest(CachedResource::Type, const KURL&, bool forPreload = false); 119 120 121 void garbageCollectDocumentResourcesTimerFired(Timer<CachedResourceLoader>*); 120 122 void performPostLoadActions(); 121 123 … … 133 135 }; 134 136 Deque<PendingPreload> m_pendingPreloads; 137 138 Timer<CachedResourceLoader> m_garbageCollectDocumentResourcesTimer; 135 139 136 140 //29 bits left
Note: See TracChangeset
for help on using the changeset viewer.