Skip to content

UsageTracker: Possible demo issue with integer division. #73

Description

@jchoover

LIndTop := (Cardinal(LMBI.BaseAddress) + Cardinal(LMBI.RegionSize)) div 65536;

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions