summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMatt Holgate <matt@emobix.co.uk>2014-06-18 11:10:44 +0100
committerMatt Holgate <matt@emobix.co.uk>2014-06-18 11:10:44 +0100
commit13e3327167cf47aa7c202ed83835bf43169ac8c1 (patch)
treede4cd06f1f0dcda15bef6d642928fe85ec578a37 /include
parentd5a22b7c76c7c0f67f9350b2a7a5dc030b212421 (diff)
downloadmupdf-13e3327167cf47aa7c202ed83835bf43169ac8c1.tar.xz
Fix for bug #694405 - iOS Pdf Crash
If an iOS app uses too much memory, the OS asks it to free up some space. If it doesn't do so in a timely manner, it will get a second warning before being killed by the OS. In other platforms, where malloc() return NULL in OOM, the store scavenger releases memory when mallocs fail. In iOS, mallocs usually never return NULL because the app is killed before this can happen. Therefore, we need to initiate a scavenge from the low memory notification instead. We evict the store to 50% of its current size when a memory warning occurs when it is in the foreground, and 0% when a memory warning occurs whilst it is in the background. Having said this, I didn't manage to get a background warning to occur, presumably because we don't request background execution Therefore, I think in practice the OS just kills the process. However, this will be useful if we ever add background execution.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/store.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/mupdf/fitz/store.h b/include/mupdf/fitz/store.h
index dc832b54..f954e3b8 100644
--- a/include/mupdf/fitz/store.h
+++ b/include/mupdf/fitz/store.h
@@ -184,6 +184,17 @@ void fz_empty_store(fz_context *ctx);
int fz_store_scavenge(fz_context *ctx, unsigned int size, int *phase);
/*
+ fz_shrink_store: Evict items from the store until the total size of
+ the objects in the store is reduced to a given percentage of its
+ current size.
+
+ percent: %age of current size to reduce the store to.
+
+ Returns non zero if we managed to free enough memory, zero otherwise.
+*/
+int fz_shrink_store(fz_context *ctx, unsigned int percent);
+
+/*
fz_print_store: Dump the contents of the store for debugging.
*/
#ifndef NDEBUG