FastMM4
FastMM4 copied to clipboard
Optional sort by name in `LogMemoryManagerStateToFile`
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 toSystem.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);
-