Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional sort by name in LogMemoryManagerStateToFile #64

Open
jpluimers opened this issue Dec 11, 2018 · 0 comments
Open

Optional sort by name in LogMemoryManagerStateToFile #64

jpluimers opened this issue Dec 11, 2018 · 0 comments

Comments

@jpluimers
Copy link

Currently this method sorts by TotalMemoryUsage:

function LogMemoryManagerStateToFile(const AFileName: string; const AAdditionalDetails: string = ''): Boolean;

For monitoring live memory allocations in an application, and comparing before/after in a call stack, it can make sense to have a different sort order, for instance on the "Name" or InstanceCount of the TMemoryLogNode item.

As far as I can see now this would require a couple of changes:

  • introduce a mechanism to specify the sort order (could as simple as an enumeration type or set of enumeration type with default value to mean TotalMemoryUsage)
  • abstract the name generation part of LogMemoryManagerStateToFile into a separate method
  • abstract comparison of two TMemoryLogNode items into a separate method similar to System.Generic.Collections.TList.Sort (IComparer<T>) but without using interfaces (and implementations that avoid allocating heap memory)
  • adopt these methods to allow for a different sorting mechanism:
    • procedure QuickSortLogNodes(APLeftItem: PMemoryLogNodes; ARightIndex: Integer);
    • procedure InsertionSortLogNodes(APLeftItem: PMemoryLogNodes; ARightIndex: Integer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant