TPdfThumbnailCacheStatistics = record
EntryCount: Integer;
StoredBytes: Int64;
HitCount: Int64;
MissCount: Int64;
EvictionCount: Int64;
end;
EntryCount includes positive bitmap entries and cached absence of optional embedded thumbnails
StoredBytes estimates bitmap memory as width times height times four bytes and excludes zero-byte negative entries
Hit, miss and eviction counters are cumulative across the lifetime of the TPdf instance
property ThumbnailCacheMaxEntries: Integer; // default 64
property ThumbnailCacheMaxBytes: Int64; // default 64 MiB
ThumbnailCacheMaxEntries caps how many entries the cache retains and ThumbnailCacheMaxBytes caps their combined bitmap estimate
The cache retains an entry only whilst both ceilings permit it and evicts the least recently used entries when either ceiling shrinks
Setting either ceiling to zero disables retention whilst leaving extraction and rendering available
Negative values raise EPdfError
property ThumbnailCacheStatistics: TPdfThumbnailCacheStatistics;
ThumbnailCacheStatistics snapshots the current counters into a TPdfThumbnailCacheStatistics record whose fields are described under Statistics type
Repeated ExtractThumbnail and RenderPageThumbnail calls contribute hits and misses under the same render lock used by native PDFium page access
Every successful bitmap lookup returns a deep caller-owned copy, so freeing or modifying it cannot affect a later hit
property ThumbnailRevision: Int64;
ThumbnailRevision is a monotonic counter that starts at one and advances whenever retained previews are cleared or a page revision changes
The value advances when page content or document structure can make an existing preview stale
TPdfThumbnailView observes this revision and discards its visible-page hot copies before repainting edited content
procedure ClearThumbnailCache;
ClearThumbnailCache drops every retained entry at once under the render lock
Releases retained bitmap and negative entries without changing limits, cumulative counters, active page or document content revision
Rendered entries are separated by page revision, page number, requested maximum size, rotation, render options, background and every TPdfColorScheme field
Embedded thumbnails use a separate source key and cache both decoded bitmaps and the absence of a page /Thumb entry
Page edits invalidate that page, whilst document replacement and page-tree changes clear all retained thumbnails
var
Bitmap: TBitmap;
Stats: TPdfThumbnailCacheStatistics;
begin
Pdf.ThumbnailCacheMaxEntries := 128;
Pdf.ThumbnailCacheMaxBytes := Int64(96) * 1024 * 1024;
Bitmap := Pdf.RenderPageThumbnail(1, 180, 240);
try
Image1.Picture.Assign(Bitmap);
finally
Bitmap.Free;
end;
Stats := Pdf.ThumbnailCacheStatistics;
LogCache(Stats.EntryCount, Stats.HitCount, Stats.MissCount);
end;