12011-08-01 Scott Graham <scottmg@chromium.org>
2
3 REGRESSION (r39725?): Resources removed from document can not be freed
4 until the document is deleted
5 https://bugs.webkit.org/show_bug.cgi?id=61006
6
7 Reviewed by Antti Koivisto.
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 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. Test added for crash discovered in
21 previous revision, but no tests for memory usage.
22
23 Test: http/tests/inspector/network/disabled-cache-crash.html
24
25 * WebCore.exp.in:
26 * loader/cache/CachedResource.h:
27 (WebCore::CachedResource::hasOneHandle):
28 * loader/cache/CachedResourceLoader.cpp:
29 (WebCore::CachedResourceLoader::CachedResourceLoader):
30 (WebCore::CachedResourceLoader::loadDone):
31 (WebCore::CachedResourceLoader::garbageCollectDocumentResourcesTimerFired):
32 * loader/cache/CachedResourceLoader.h:
33 * testing/Internals.cpp:
34 (WebCore::Internals::disableMemoryCache):
35 * testing/Internals.h:
36 * testing/Internals.idl:
37