FastMM4
FastMM4 copied to clipboard
UsageTracker: Possible demo issue with integer division.
https://github.com/pleriche/FastMM4/blob/bed3021e5e543108b4a81e24107a43c68bd93dcd/Demos/Usage%20Tracker/FastMMUsageTracker.pas#L525
When using this demo with the Default MM of Delphi 10.2, (Removed the FasMM from the uses clauses), I noticed that the logic for calculating total allocated pages is using integer division. In my use case, the LMBI.RegionSize is NOT an interval of PageSize, so the integer division "misses" the last page, causing it to sit in an infinite loop.
Changing that line to
LIndTop := Ceil((Cardinal(LMBI.BaseAddress) + Cardinal(LMBI.RegionSize)) / 65536);
And adding Math to the uses clause fixed my issue.