7.3 Reacting to Out of Memory events

As a last resort, applications using MuPDF can react to low memory events by changing their strategy. For example, if we fail to render a band of data due to an allocation failure, we might back off and try a smaller band size. Alternatively, we might choose to dispense with the display list, and to reinterpret the underlying file directly each time, trading speed for memory.

To this end, all exceptions thrown due to allocation failures have the FZ_ERROR_MEMORY type, enabling callers to easily distinguish them using fz_caught and to react accordingly.

7.3.1 Implementation

Further information on The Store can be found in chapterĀ 21 Store Internals in Part II.