Commit 3076b4b5 authored by mitz@apple.com's avatar mitz@apple.com
Browse files

WebCore:

        Reviewed by Sam Weinig.

        - WebCore part of https://bugs.webkit.org/show_bug.cgi?id=21736
          Long-dead decoded image data make up for most of the object cache's memory use over time

        Add a cache setting for how long decoded image data should be allowed to
        persist in memory after the image has died. By default, this is set to
        0, which means "forever".

        * loader/Cache.cpp:
        (WebCore::Cache::Cache): Initialize m_deadDecodedDataDeletionInterval.
        * loader/Cache.h:
        (WebCore::Cache::setDeadDecodedDataDeletionInterval): Added a setter.
        (WebCore::Cache::deadDecodedDataDeletionInterval): Added a getter.
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::CachedImage): Initialize the decoded data
        deletion timer.
        (WebCore::CachedImage::decodedDataDeletionTimerFired): Added. Destroys
        the decoded image data.
        (WebCore::CachedImage::addClient): Stop the timer if it is active.
        (WebCore::CachedImage::allClientsRemoved): Start the decoded data
        deletion timer.
        * loader/CachedImage.h:

WebKit/mac:

        Reviewed by Sam Weinig.

        - WebKit/mac part of https://bugs.webkit.org/show_bug.cgi?id=21736
          Long-dead decoded image data make up for most of the object cache's memory use over time

        * WebView/WebView.mm:
        (+[WebView _setCacheModel:]): In the primary web browser model, set the
        cache's dead decoded data deletion interval to 60 seconds.

WebKit/win:

2008-10-18  Dan Bernstein  <mitz@apple.com>

        Reviewed by Sam Weinig.

        - WebKit/win part of https://bugs.webkit.org/show_bug.cgi?id=21736
          Long-dead decoded image data make up for most of the object cache's memory use over time

        * WebView.cpp:
        (WebView::setCacheModel): In the primary web browser model,
        set the cache's dead decoded data deletion interval to 60 seconds.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f20ce333
2008-10-18 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
- WebCore part of https://bugs.webkit.org/show_bug.cgi?id=21736
Long-dead decoded image data make up for most of the object cache's memory use over time
Add a cache setting for how long decoded image data should be allowed to
persist in memory after the image has died. By default, this is set to
0, which means "forever".
* loader/Cache.cpp:
(WebCore::Cache::Cache): Initialize m_deadDecodedDataDeletionInterval.
* loader/Cache.h:
(WebCore::Cache::setDeadDecodedDataDeletionInterval): Added a setter.
(WebCore::Cache::deadDecodedDataDeletionInterval): Added a getter.
* loader/CachedImage.cpp:
(WebCore::CachedImage::CachedImage): Initialize the decoded data
deletion timer.
(WebCore::CachedImage::decodedDataDeletionTimerFired): Added. Destroys
the decoded image data.
(WebCore::CachedImage::addClient): Stop the timer if it is active.
(WebCore::CachedImage::allClientsRemoved): Start the decoded data
deletion timer.
* loader/CachedImage.h:
2008-10-18 Darin Adler <darin@apple.com>
 
Reviewed by Dan Bernstein.
......
......@@ -44,6 +44,7 @@ namespace WebCore {
static const int cDefaultCacheCapacity = 8192 * 1024;
static const double cMinDelayBeforeLiveDecodedPrune = 1; // Seconds.
static const float cTargetPrunePercentage = .95f; // Percentage of capacity toward which we prune, to avoid immediately pruning again.
static const double cDefaultDecodedDataDeletionInterval = 0;
Cache* cache()
{
......@@ -58,6 +59,7 @@ Cache::Cache()
, m_capacity(cDefaultCacheCapacity)
, m_minDeadCapacity(0)
, m_maxDeadCapacity(cDefaultCacheCapacity)
, m_deadDecodedDataDeletionInterval(cDefaultDecodedDataDeletionInterval)
, m_liveSize(0)
, m_deadSize(0)
{
......
......@@ -125,6 +125,9 @@ public:
pruneLiveResources();
}
void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; }
double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
// Remove an existing cache entry from both the resource map and from the LRU list.
void remove(CachedResource* resource) { evict(resource); }
......@@ -179,6 +182,7 @@ private:
unsigned m_capacity;
unsigned m_minDeadCapacity;
unsigned m_maxDeadCapacity;
double m_deadDecodedDataDeletionInterval;
unsigned m_liveSize; // The number of bytes currently consumed by "live" resources in the cache.
unsigned m_deadSize; // The number of bytes currently consumed by "dead" resources in the cache.
......
......@@ -49,6 +49,7 @@ namespace WebCore {
CachedImage::CachedImage(const String& url)
: CachedResource(url, ImageResource)
, m_image(0)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
{
m_status = Unknown;
}
......@@ -56,6 +57,7 @@ CachedImage::CachedImage(const String& url)
CachedImage::CachedImage(Image* image)
: CachedResource(String(), ImageResource)
, m_image(image)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
{
m_status = Cached;
m_loading = false;
......@@ -64,7 +66,13 @@ CachedImage::CachedImage(Image* image)
CachedImage::~CachedImage()
{
}
void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*)
{
ASSERT(!hasClients());
destroyDecodedData();
}
void CachedImage::load(DocLoader* docLoader)
{
if (!docLoader || docLoader->autoLoadImages())
......@@ -77,6 +85,9 @@ void CachedImage::addClient(CachedResourceClient* c)
{
CachedResource::addClient(c);
if (m_decodedDataDeletionTimer.isActive())
m_decodedDataDeletionTimer.stop();
if (m_image && !m_image->rect().isEmpty())
c->imageChanged(this);
......@@ -88,6 +99,8 @@ void CachedImage::allClientsRemoved()
{
if (m_image && !m_errorOccurred)
m_image->resetAnimation();
if (double interval = cache()->deadDecodedDataDeletionInterval())
m_decodedDataDeletionTimer.startOneShot(interval);
}
static Image* brokenImage()
......
......@@ -27,6 +27,7 @@
#include "ImageObserver.h"
#include "Image.h"
#include "IntRect.h"
#include "Timer.h"
#include <wtf/Vector.h>
namespace WebCore {
......@@ -88,8 +89,10 @@ public:
private:
void createImage();
void notifyObservers();
void decodedDataDeletionTimerFired(Timer<CachedImage>*);
RefPtr<Image> m_image;
Timer<CachedImage> m_decodedDataDeletionTimer;
};
}
......
2008-10-18 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
- WebKit/mac part of https://bugs.webkit.org/show_bug.cgi?id=21736
Long-dead decoded image data make up for most of the object cache's memory use over time
* WebView/WebView.mm:
(+[WebView _setCacheModel:]): In the primary web browser model, set the
cache's dead decoded data deletion interval to 60 seconds.
2008-10-15 Mark Rowe <mrowe@apple.com>
Reviewed by Jon Honeycutt.
......
......@@ -4271,6 +4271,7 @@ static WebFrameView *containingFrameView(NSView *view)
unsigned cacheTotalCapacity = 0;
unsigned cacheMinDeadCapacity = 0;
unsigned cacheMaxDeadCapacity = 0;
double deadDecodedDataDeletionInterval = 0;
unsigned pageCacheCapacity = 0;
......@@ -4389,6 +4390,8 @@ static WebFrameView *containingFrameView(NSView *view)
// can prove that the overall system gain would justify the regression.
cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
deadDecodedDataDeletionInterval = 60;
// Foundation memory cache capacity (in bytes)
// (These values are small because WebCore does most caching itself.)
if (memSize >= 1024)
......@@ -4430,6 +4433,7 @@ static WebFrameView *containingFrameView(NSView *view)
nsurlCacheDiskCapacity = max(nsurlCacheDiskCapacity, [nsurlCache diskCapacity]);
cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
pageCache()->setCapacity(pageCacheCapacity);
[nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity];
[nsurlCache setDiskCapacity:nsurlCacheDiskCapacity];
......
2008-10-18 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
- WebKit/win part of https://bugs.webkit.org/show_bug.cgi?id=21736
Long-dead decoded image data make up for most of the object cache's memory use over time
* WebView.cpp:
(WebView::setCacheModel): In the primary web browser model,
set the cache's dead decoded data deletion interval to 60 seconds.
2008-10-16 Kevin McCullough <kmccullough@apple.com>
 
Reviewed by Steve Falkenburg.
......
......@@ -382,6 +382,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
unsigned cacheTotalCapacity = 0;
unsigned cacheMinDeadCapacity = 0;
unsigned cacheMaxDeadCapacity = 0;
double deadDecodedDataDeletionInterval = 0;
unsigned pageCacheCapacity = 0;
......@@ -500,6 +501,8 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
// can prove that the overall system gain would justify the regression.
cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
deadDecodedDataDeletionInterval = 60;
// Foundation memory cache capacity (in bytes)
// (These values are small because WebCore does most caching itself.)
if (memSize >= 1024)
......@@ -535,6 +538,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
cfurlCacheDiskCapacity = max(cfurlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlSharedCache));
cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
pageCache()->setCapacity(pageCacheCapacity);
CFURLCacheSetMemoryCapacity(cfurlSharedCache, cfurlCacheMemoryCapacity);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment