Jump to content
Alberto Paganini

Fixing memory leaks with FastMM4

Recommended Posts

I have started removing memory leaks in my application and installed and configured FastMM4. 

I ran the application and the following is an excerpt from the memory leaks report.

--------------------------------2020/6/20 21:24:00--------------------------------
A memory block has been leaked. The size is: 100

This block was allocated by thread 0x13C4, and the stack trace (return addresses) at the time was:
404DA6 [System.pas][System][@GetMem$qqri][3454]
406E0F [System.pas][System][TObject.NewInstance$qqrv][13000]
40747E [System.pas][System][@ClassCreate$qqrpvzc][14164]
45926E [System.Classes.pas][System.Classes][Classes.TStringList.$bctr$qqrv][6408]
EAF697 [uBetFairAPIHorseHelperBL.pas][uBetFairAPIHorseHelperBL][TBetFairAPIHorseHelperBL.ResetEventID$qqrv][921]
EAED20 [uBetFairAPIHorseHelperBL.pas][uBetFairAPIHorseHelperBL][TBetFairAPIHorseHelperBL.ListEvents$qqr20System.UnicodeString][611]
D4C0EB [DBAccess][TCustomDADataSet.GetRecordCount$qqrv]
E92D6A [uTokenBL.pas][uTokenBL][TTokenBL.GetTokenID$qqrv][34]
E5A73D [Main.pas][Main][TMainForm.btnFindRacesClick$qqrp14System.TObject][190]
E5B5C5 [Main.pas][Main][TMainForm.FormActivate$qqrp14System.TObject][418]
557E7D [Vcl.Forms][Forms.TCustomForm.Activate$qqrv]

The block is currently used for an object of class: System.Classes.TStringList

The allocation number is: 199660

Current memory dump of 256 bytes starting at pointer address 7F322C00:
2C A7 44 00 00 00 00 00 00 00 00 00 40 B7 A9 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 01 00 00 00 88 40 34 7F 01 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FC CD 79
80 80 80 80 80 80 80 80 00 00 00 00 01 33 32 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
99 E6 0B 00 A6 4D 40 00 0F 6E 40 00 7E 74 40 00 6E 92 45 00 18 6E 40 00 7E 74 40 00 2D 37 D7 00
CA 53 D7 00 A3 11 DA 00 93 E9 D3 00 A8 4F D4 00 C4 13 00 00 C4 13 00 00 C2 4D 40 00 2D 6E 40 00
C9 74 40 00 23 8B 45 00 73 6E 40 00 8E 37 D7 00 73 6E 40 00 67 54 D7 00 ED 11 DA 00 73 6E 40 00
EB 37 CD 00 5C 00 00 00 2C A7 44 00 26 3A 59 8A 94 A2 F1 00 80 80 80 80 80 80 80 80 80 80 80 80
,  §  D  .  .  .  .  .  .  .  .  .  @  ·  ©  �  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  ˆ  @  4  �  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  ÿ  ü  Í  y
€  €  €  €  €  €  €  €  .  .  .  .  .  3  2  �  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
™  æ  .  .  ¦  M  @  .  .  n  @  .  ~  t  @  .  n  ’  E  .  .  n  @  .  ~  t  @  .  -  7  ×  .
Ê  S  ×  .  £  .  Ú  .  “  é  Ó  .  ¨  O  Ô  .  Ä  .  .  .  Ä  .  .  .  Â  M  @  .  -  n  @  .
É  t  @  .  #  ‹  E  .  s  n  @  .  Ž  7  ×  .  s  n  @  .  g  T  ×  .  í  .  Ú  .  s  n  @  .
ë  7  Í  .  \  .  .  .  ,  §  D  .  &  :  Y  Š  ”  ¢  ñ  .  €  €  €  €  €  €  €  €  €  €  €  €


 

As this is the first time I use FastMM4 I don't know how to start to fix the leaks.

Can somebody point out a tutorial that starts from scratch on this topic?

 

Many thanks

Alberto

Share this post


Link to post
26 minutes ago, Alexander Sviridenkov said:

Looks like TStringList is created in TBetFairAPIHorseHelperBL.ResetEventID and never destroyed.

Thank you very much for your answer, Alexander. Is there anything on the web that teaches how to read the report?

Share this post


Link to post

Report is quite simple. First part is call stack, Usually top items are from RTL and gives you little info, so skip items from top until you'll find your own unit, this will be class/method where leaked block was created,

Second section is (possible) class that uses this block.

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×