summaryrefslogtreecommitdiff
path: root/desktop/netsurf.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-09-10 00:55:39 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-09-10 00:55:39 +0000
commit2d33a8f85a83ceaf55dd5ab6a9e363191bfe3c08 (patch)
treec470aa1525dc7835bf2918ccab4138f956f7f828 /desktop/netsurf.c
parentcbeffd4c5f4ac2ecbb2cfc97a705441a20ec8f23 (diff)
downloadnetsurf-2d33a8f85a83ceaf55dd5ab6a9e363191bfe3c08.tar.gz
netsurf-2d33a8f85a83ceaf55dd5ab6a9e363191bfe3c08.tar.bz2
Make high level cache, low level cache and image cache all be initialised from passed parameters
Calculate all cache sizes from single memory cache size option and sanity check have a single global struct to hold all parameters instead of several individual variables svn path=/trunk/netsurf/; revision=12784
Diffstat (limited to 'desktop/netsurf.c')
-rw-r--r--desktop/netsurf.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 37e06a330..cb63e7d6b 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -70,7 +70,7 @@
/* the time between cache clean runs in ms */
#define IMAGE_CACHE_CLEAN_TIME (10 * 1000)
-#define HL_CACHE_CLEAN_TIME (5 * 1000)
+#define HL_CACHE_CLEAN_TIME (2 * IMAGE_CACHE_CLEAN_TIME)
bool netsurf_quit = false;
bool verbose_log = false;
@@ -109,6 +109,8 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
return NSERROR_OK;
}
+#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
+
/**
* Initialise components used by gui NetSurf.
*/
@@ -127,11 +129,9 @@ nserror netsurf_init(int *pargc,
};
struct image_cache_parameters image_cache_parameters = {
.bg_clean_time = IMAGE_CACHE_CLEAN_TIME,
- .limit = (8 * 1024 * 1024),
- .hysteresis = (2 * 1024 * 1024),
.speculative_small = SPECULATE_SMALL
};
-
+
#ifdef HAVE_SIGPIPE
/* Ignore SIGPIPE - this is necessary as OpenSSL can generate these
* and the default action is to terminate the app. There's no easy
@@ -169,6 +169,24 @@ nserror netsurf_init(int *pargc,
messages_load(messages);
+ /* set up cache limits based on the memory cache size option */
+ hlcache_parameters.limit = option_memory_cache_size;
+
+ if (hlcache_parameters.limit < MINIMUM_MEMORY_CACHE_SIZE) {
+ hlcache_parameters.limit = MINIMUM_MEMORY_CACHE_SIZE;
+ LOG(("Setting minimum memory cache size to %d",
+ hlcache_parameters.limit));
+ }
+
+ /* image cache is 25% of total memory cache size */
+ image_cache_parameters.limit = (hlcache_parameters.limit * 25) / 100;
+
+ /* image cache hysteresis is 20% of teh image cache size */
+ image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
+
+ /* account for image cache use from total */
+ hlcache_parameters.limit -= image_cache_parameters.limit;
+
/* image handler bitmap cache */
error = image_cache_init(&image_cache_parameters);
if (error != NSERROR_OK)
@@ -244,9 +262,6 @@ void netsurf_exit(void)
LOG(("Finalising high-level cache"));
hlcache_finalise();
- LOG(("Finalising low-level cache"));
- llcache_finalise();
-
LOG(("Closing fetches"));
fetch_quit();