Recent

Author Topic: [Solved] Memory leak when selecting font in panel  (Read 1058 times)

Wilko500

  • Full Member
  • ***
  • Posts: 180
[Solved] Memory leak when selecting font in panel
« on: September 11, 2025, 12:23:10 am »
Have been doing work looking for memory leaks on my application.  One bug report has been submitted by WP responding to my post on memory leak using Chart.  Seems to actually be a problem with canvas painting.

This one is similar, I think.  Create a new project, place a panel on the form, select a font for its caption.  On program close 2 unfreed blocks.  The hepatrc output is not helpful
Code: Pascal  [Select][+][-]
  1. Heap dump by heaptrc unit of /Volumes/MacHD-SSD-Data/LocBucket/FpLazStuff/BBB//project1
  2. 756 memory blocks allocated : 1109692/1110392
  3. 754 memory blocks freed     : 1109613/1110312
  4. 2 unfreed memory blocks : 79
  5. True heap size : 1736704 (96 used in System startup)
  6. True free heap : 1736096
  7. Should be : 1736144
  8. Call trace for block $00000001E476FD00 size 48
  9.   $000000010A4FFE41
  10.   $000000010A38C2F6
  11.   $000000010A37B96A
  12.   $000000010A37BFAA
  13.   $000000010A4A3AF7
  14.   $000000010A3FC8A5
  15.   $000000010A208A59
  16.   $000000010A3FC4DF
  17.   $000000010A203700
  18.   $000000010A20DB2C
  19.   $000000010A20F279
  20.   $000000010A3FBB07
  21.   $000000010A3FD231
  22. Call trace for block $00000001E4770000 size 31
  23.   $000000010A257D83
  24.   $000000010A25729F
  25.   $000000010A2569F6
  26.   $000000010A255CD9
  27.   $000000010A2579DA
  28.   $000000010A3A6D04
  29.   $000000010A39E610
  30.   $000000010A20BB2B
  31.   $000000010A20B9B8
  32.   $000000010A20F353
  33.  
I have tried multiple fonts, Tahoma, Comic Sans, Times New Roman all seem to create the memory leak. Selecting a font for the form itself does not seem to give a memory leak so perhaps it's not the font but the way it is painted on the panel?
I don't know how to debug this further.
« Last Edit: September 26, 2025, 06:07:21 pm by Wilko500 »
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Memory leak when selecting font in panel
« Reply #1 on: September 11, 2025, 12:38:08 am »
So the plot thickens.  Another control I use on my application is object TA3nalogGauge from the Industrial package.  Create a new project, drop the TA3nalogGauge control on the form.  On program exit 2 unfreed memory blocks
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

wp

  • Hero Member
  • *****
  • Posts: 13210
Re: Memory leak when selecting font in panel
« Reply #2 on: September 11, 2025, 01:10:29 am »
So the plot thickens.  Another control I use on my application is object TA3nalogGauge from the Industrial package.  Create a new project, drop the TA3nalogGauge control on the form.  On program exit 2 unfreed memory blocks
TA3nalogGauge does a lot of painting, also painting of text. This leak thus may have the same origin.

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Memory leak when selecting font in panel
« Reply #3 on: September 26, 2025, 06:07:05 pm »
Marking this as solved.  Seems to have the same canvass drawing problem that has now been fixed
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

wp

  • Hero Member
  • *****
  • Posts: 13210
Re: [Solved] Memory leak when selecting font in panel
« Reply #4 on: September 26, 2025, 06:26:10 pm »
Great! It is always amazing which effect a missing line in the source (Font := DefaultFont) can have!

 

TinyPortal © 2005-2018