PDFium Delphi Component Docs

TPdf cache governor properties

Component: TPdf  ·  Units: PDFium, FPdfCache
Coordinates retained page scenes, thumbnails, structure data, text snapshots, and page-object snapshots under one measurable byte ceiling

CacheBudgetBytes

property CacheBudgetBytes: Int64; // default 256 MiB

Changing the value applies immediately across every participating cache owned by this TPdf instance

Setting the value to zero disables new retention and evicts every inactive entry

Negative values raise EPdfError

Active parsed page scenes are pinned and may keep measured usage temporarily above a reduced budget until rendering releases them

CacheGovernor

property CacheGovernor: TPdfCacheGovernor; // read-only, owned by TPdf

Returns the shared governor for per-kind usage queries and optional coordination with application-owned caches

Do not free the returned object and do not retain it after the owning TPdf instance is destroyed

Callers may register pckApplication entries through a participant that follows the FPdfCache callback and lifetime contract

CacheGovernorStatistics

property CacheGovernorStatistics: TPdfCacheGovernorStatistics;

Returns current and peak measured bytes, pinned bytes, entry count, reservation and touch activity, evictions, and rejected reservations

The snapshot covers retained library cache entries only

Caller-owned bitmap copies and returned snapshot copies remain outside the budget, whilst decoded-stream reads remain ephemeral and retain their existing per-operation hard limits

Measurement model

Bitmap caches use width times height times four bytes

Managed snapshot caches include record arrays, strings, byte buffers, path segments, clip data, marks, image metadata, and nested values

Parsed PDFium page scenes are opaque native handles and receive an 8 MiB accounting charge per retained scene rather than a claim of exact native heap use

Example

var
  Stats: TPdfCacheGovernorStatistics;
begin
  Pdf.CacheBudgetBytes := Int64(128) * 1024 * 1024;
  Stats := Pdf.CacheGovernorStatistics;
  LogCacheUsage(Stats.StoredBytes, Stats.PeakStoredBytes,
    Pdf.CacheGovernor.UsageForKind(pckThumbnail));
end;

See Also

FPdfCache, Thumbnail cache, PageSceneCacheCapacity, Structure cache, Text snapshot cache, Page-object snapshot cache