Peak Memory Scheduling
HotPDF admits competing high-footprint operations through one process-wide byte budget before they allocate their main working sets
Covered operations
- Document loading
- Synchronous, cached, and progressive page rendering
- Parallel page, tile, and band rendering
- Selective stream optimisation
- Bounded parallel image optimisation
Each operation reserves a conservative estimate derived from its source size, render dimensions, DPI, stream threshold, and worker count, then releases the reservation at the existing operation telemetry boundary
Admission policy
- The default process-wide budget is
536870912bytes - A value of
0disables budget limiting - Waiters are admitted in FIFO order so later small requests cannot starve an earlier large request
- A request larger than the configured budget may run only when no other reservation is active
- Increasing the budget can admit queued work immediately, whilst decreasing it never interrupts active work
- Queued waits poll the operation cancellation token at bounded 50 ms intervals
The uncontended path allocates no wait event, whilst contended operations use one private event and do not spin
Configuration
PDF.PeakMemorySchedulerEnabled := True;
PDF.PeakMemorySchedulerBudgetBytes := 768 * 1024 * 1024;
PDF.ResetPeakMemorySchedulerStatistics;
if PDF.GetPeakMemorySchedulerStatistics(Stats) then
begin
WriteLn(Stats.PeakReservedBytes);
WriteLn(Stats.DelayedAdmissionCount);
WriteLn(Stats.TotalWaitMilliseconds);
end;
PeakMemorySchedulerEnabled is per component and can bypass admission for trusted isolated work, whilst PeakMemorySchedulerBudgetBytes configures the shared process-wide scheduler
Statistics
THPDFPeakMemorySchedulerStatistics reports current and peak reserved bytes, current and peak active reservations, current and peak waiters, total and delayed admissions, oversized admissions, cancellations, and aggregate wait time
THPDFOperationTelemetry.ScheduledMemoryBytes, MemorySchedulerWaitMilliseconds, and MemorySchedulerDelayed attribute scheduling cost to the most recent operation