Forum > Cocoa

[Solved] Memory leak when selecting font in panel

(1/1)

Wilko500:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Heap dump by heaptrc unit of /Volumes/MacHD-SSD-Data/LocBucket/FpLazStuff/BBB//project1756 memory blocks allocated : 1109692/1110392754 memory blocks freed     : 1109613/11103122 unfreed memory blocks : 79True heap size : 1736704 (96 used in System startup)True free heap : 1736096Should be : 1736144Call trace for block $00000001E476FD00 size 48  $000000010A4FFE41  $000000010A38C2F6  $000000010A37B96A  $000000010A37BFAA  $000000010A4A3AF7  $000000010A3FC8A5  $000000010A208A59  $000000010A3FC4DF  $000000010A203700  $000000010A20DB2C  $000000010A20F279  $000000010A3FBB07  $000000010A3FD231Call trace for block $00000001E4770000 size 31  $000000010A257D83  $000000010A25729F  $000000010A2569F6  $000000010A255CD9  $000000010A2579DA  $000000010A3A6D04  $000000010A39E610  $000000010A20BB2B  $000000010A20B9B8  $000000010A20F353 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.

Wilko500:
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

wp:

--- Quote from: Wilko500 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

--- End quote ---
TA3nalogGauge does a lot of painting, also painting of text. This leak thus may have the same origin.

Wilko500:
Marking this as solved.  Seems to have the same canvass drawing problem that has now been fixed

wp:
Great! It is always amazing which effect a missing line in the source (Font := DefaultFont) can have!

Navigation

[0] Message Index

Go to full version