control renderer memory usage #80

added setCacheSize and cache_document_size configuration vairable
pull/2/merge
Dobrica Pavlinusic 12 years ago
parent 92ec4213c0
commit 91bd1277d7

@ -455,6 +455,14 @@ static int getCacheSize(lua_State *L) {
return 1;
}
static int setCacheSize(lua_State *L) {
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
int size = luaL_checkint(L, 2);
printf("ddjvu_cache_set_size = %d\n", size);
ddjvu_cache_set_size(doc->context, size);
return 0;
}
static const struct luaL_Reg djvu_func[] = {
{"openDocument", openDocument},
{NULL, NULL}
@ -467,6 +475,7 @@ static const struct luaL_Reg djvudocument_meth[] = {
{"getPageText", getPageText},
{"close", closeDocument},
{"getCacheSize", getCacheSize},
{"setCacheSize", setCacheSize},
{"__gc", closeDocument},
{NULL, NULL}
};

@ -72,6 +72,8 @@ UniReader = {
-- tile cache state:
cache_current_memsize = 0,
cache = {},
-- renderer cache size
cache_document_size = 1024*1024*8, -- FIXME random, needs testing
pagehash = nil,
@ -134,6 +136,11 @@ function UniReader:getCacheSize()
return -1
end
function UniReader:setCacheSize(size)
return
end
--[ following are default methods ]--
function UniReader:loadSettings(filename)
@ -158,6 +165,8 @@ function UniReader:loadSettings(filename)
self.globalzoom = self.settings:readSetting("globalzoom") or 1.0
self.globalzoommode = self.settings:readSetting("globalzoommode") or -1
self.doc:setCacheSize( self.cache_document_size )
return true
end
return false

Loading…
Cancel
Save