PDFium Delphi Component Docs

CacheGovernorStatistics property

Component: TPdf  ·  Unit: PDFium
Returns a consistent snapshot of byte usage, pinning, and reservation telemetry for the per-instance cache governor

Syntax

property CacheGovernorStatistics: TPdfCacheGovernorStatistics; // read only

 

type TPdfCacheGovernorStatistics = record
  MaxBytes: Int64;
  StoredBytes: Int64;
  PeakStoredBytes: Int64;
  PinnedBytes: Int64;
  EntryCount: Integer;
  ReservationCount: Int64;
  TouchCount: Int64;
  EvictionCount: Int64;
  RejectionCount: Int64;
end;

MaxBytesConfigured ceiling, equal to CacheBudgetBytes
StoredBytesSum of the measured bytes of all currently retained entries
PeakStoredBytesHigh-water mark of StoredBytes since the instance was created
PinnedBytesPortion of stored bytes held by pinned entries, currently active parsed page scenes
EntryCountNumber of retained entries across every participating cache
ReservationCountCumulative count of accepted cache insertions
TouchCountCumulative count of least-recently-use refreshes, one per cache hit on a retained entry
EvictionCountCumulative count of entries dropped to keep usage within the budget
RejectionCountCumulative count of insertions refused because the budget is zero, the entry alone exceeds MaxBytes, or nothing is evictable

Description

The record is declared in the FPdfCache unit and mirrors the state of the private governor described on the CacheGovernor page. The values are gathered under the governor lock, so one read returns a mutually consistent view even while other threads render or read pages

The snapshot covers retained library cache entries only. Caller-owned bitmap copies and returned snapshot copies remain outside the budget, while decoded-stream reads remain ephemeral and keep their per-operation hard limits

Counters are cumulative for the lifetime of the TPdf instance; capacity changes, cache clears, and document reloads preserve them

Remarks

An eviction is only counted when budget pressure drops an entry; releasing an entry because its page was edited or its cache was cleared explicitly is not an eviction

When the governor is unavailable the getter returns a zeroed record with every field at its default value

Example

Stats := Pdf.CacheGovernorStatistics;
if Stats.PeakStoredBytes > Pdf.CacheBudgetBytes div 2 then
  LogCachePressure(Stats.StoredBytes, Stats.EvictionCount);

See Also

CacheBudgetBytes, CacheGovernor, ThumbnailCacheStatistics, FPdfCache