TPDFlibViewerBitmapCache

Data types, viewer interaction, caching

Description

Least-recently-used bitmap cache that bounds the memory the viewer spends on rendered pages

Entries are keyed by page number plus a quantised zoom, so changing the zoom naturally retires stale renderings as the budget fills; the cache owns its bitmaps and frees them on eviction

A bitmap larger than the whole budget is still stored alone so the viewer can always show the current page

The class is pure code with no window dependency, which keeps it testable headlessly; the viewer exposes its instance through the Cache property and resizes the budget through SetCacheLimit

Declaration

TPDFlibViewerBitmapCache = class

Key members

CreateBuilds the cache with a byte budget given by AMaxBytes
GetReturns the cached bitmap and marks it most recently used, or Nil on a miss
PutStores a bitmap under a key and takes ownership; evicts least recently used entries until the budget holds
RemovePageDrops every entry of one page across all zoom and rotation keys
ClearFrees every cached bitmap
CountNumber of retained bitmaps
UsedBytesBytes currently held
MaxBytesMemory budget in bytes, writable at runtime

See also

Cache, SetCacheLimit, IsPageCached, TPDFlibViewer