The (relatively) new LogMemoryManagerStateToFile function was a great tool to help me track down some live leaks (growing memory usage).
While I as at it, I easily identified class allocations that caused more memory usage than anticipated. Being lazy, instead of manually dividing total size with number of instances, I patched the code to calculate and output this automatically.
This gives me a log like:
Usage Detail:
2281916 bytes: UnicodeString x 25625 = 89
1018152 bytes: Unknown x 2396 = 424
603536 bytes: TFeed x 2252 = 268
164948 bytes: TExchange x 959 = 172
133120 bytes: TSmartList x 2560 = 52
80592 bytes: TProvider x 92 = 876
The number after the equals sign is the "average" allocation size. For classes, this is the same as InstanceSize, of course, but it is just handy to have this. And for string and unknown (raw memory blocks) it gives you an idea of the average size.
Feel free to include this in an update if you think it might benefit others as well.
Hope you are well, and thanks for the patch! When I read this I immediately recalled that I have also on occasion grabbed the calculator to calculate the average size, so it will definitely be useful to have this. I'm just going to change the presentation slightly so it is very clear that it is an average that is being displayed and then commit it to the repository.
Thanks again,
Pierre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Pierre,
The (relatively) new LogMemoryManagerStateToFile function was a great tool to help me track down some live leaks (growing memory usage).
While I as at it, I easily identified class allocations that caused more memory usage than anticipated. Being lazy, instead of manually dividing total size with number of instances, I patched the code to calculate and output this automatically.
This gives me a log like:
Usage Detail:
2281916 bytes: UnicodeString x 25625 = 89
1018152 bytes: Unknown x 2396 = 424
603536 bytes: TFeed x 2252 = 268
164948 bytes: TExchange x 959 = 172
133120 bytes: TSmartList x 2560 = 52
80592 bytes: TProvider x 92 = 876
The number after the equals sign is the "average" allocation size. For classes, this is the same as InstanceSize, of course, but it is just handy to have this. And for string and unknown (raw memory blocks) it gives you an idea of the average size.
Feel free to include this in an update if you think it might benefit others as well.
The patch is:
diff --git a/FastMM4.pas b/FastMM4.pas
index 7be3920..16be340 100644
--- a/FastMM4.pas
+++ b/FastMM4.pas
@@ -10187,6 +10187,13 @@ begin
LPMsg^ := ' ';
Inc(LPMsg);
LPMsg := NativeUIntToStrBuf(LPNode.InstanceCount, LPMsg);
LPMsg^ := #13;
Inc(LPMsg);
LPMsg^ := #10;
Best Regards
Hallvard Vassbotn
Hi Hallvard,
Hope you are well, and thanks for the patch! When I read this I immediately recalled that I have also on occasion grabbed the calculator to calculate the average size, so it will definitely be useful to have this. I'm just going to change the presentation slightly so it is very clear that it is an average that is being displayed and then commit it to the repository.
Thanks again,
Pierre
Thanks Pierre, good you agree it is a useful change.
I'm doing just fine, hope you are too.
Thanks for the great work you are stilling doing with FastMM! :)
/Hallvard