Hi @HH222 ,
Thank you for the detailed questions.
- Is the lifetime PeakWorkingSetSize allowed to record a temporary page above that maximum, or a peak before enforcement? The SetProcessWorkingSetSizeEx documentation says that QUOTA_LIMITS_HARDWS_MAX_ENABLE prevents the working set from exceeding the maximum. The PROCESS_MEMORY_COUNTERS documentation defines PeakWorkingSetSize as the peak working-set size. Neither reference documents a one-page allowance or specifies whether a peak recorded before the limit was applied is excluded from that lifetime value. I therefore cannot confirm either explanation from the published contract.
- Is the suspended-start sequence insufficient to cover all lifetime usage? Creating a suspended process prevents its primary thread from executing until it is resumed. That supports your sequencing of the child's code, but it does not establish when the reported lifetime peak occurred. GetProcessWorkingSetSizeEx confirms the retrieved limits and flags; it does not provide a timestamp for PeakWorkingSetSize. I would not conclude from the current readings alone that the excess occurred either before or after resumption.
- What authoritative contract or supported diagnostic can distinguish these cases? As a targeted diagnostic, you could capture GetProcessMemoryInfo immediately after applying the limit while the child remains suspended, then compare PeakWorkingSetSize with readings after ResumeThread and at the existing checkpoints. That comparison may show whether the excess was already present before the child's primary thread ran. It would narrow the timing, but would not by itself explain why the peak exceeded the configured maximum.
Microsoft also documents QueryWorkingSet and QueryWorkingSetEx for examining working-set pages, and GetWsChanges for monitoring pages added to a working set. These can provide additional evidence, but they do not supply a documented exception to the hard maximum or an authoritative explanation of this particular peak.
I hope this helps.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.