Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
Treeview memory leak
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Single / Double / Float s...
by
tetrastes
[
Today
at 11:01:15 am]
FPC 3.2.4-rc1 available
by
marcov
[
Today
at 10:47:38 am]
[SOLVED] Lazreport. Multi...
by
Petrus Vorster
[
Today
at 09:27:32 am]
exception external SIGSEG...
by
dseligo
[
Today
at 07:57:12 am]
Has anyone installed TeeB...
by
egsuh
[
Today
at 06:34:29 am]
Commerce website written ...
by
Handoko
[
Today
at 05:24:32 am]
Hashing pointers by using...
by
440bx
[
Today
at 01:15:38 am]
Introducing PasBuild 1.0....
by
dbannon
[December 11, 2025, 11:54:37 pm]
[SOLVED] Program compiles...
by
Schmitty2005
[December 11, 2025, 07:35:39 pm]
TIBDataSet "Closing"? on ...
by
RedOctober
[December 11, 2025, 05:00:04 pm]
So many "newbies"
by
gidesa
[December 11, 2025, 04:18:38 pm]
How can I make a safe app...
by
LeP
[December 11, 2025, 03:30:34 pm]
[SOLVED] Need help conver...
by
srvaldez
[December 11, 2025, 01:52:33 pm]
SpkToolbar custom update
by
wp
[December 11, 2025, 01:48:16 pm]
OS/2 Warp 4 problem with ...
by
Thaddy
[December 11, 2025, 01:35:10 pm]
Is FPGUI still active?
by
BSaidus
[December 11, 2025, 01:25:31 pm]
Bitmap into Paintbox
by
BubikolRamios
[December 11, 2025, 12:58:20 pm]
Notetask 1.1.0 - Free cro...
by
AlexanderT
[December 11, 2025, 12:11:14 pm]
Matching video to form
by
Pe3s
[December 11, 2025, 10:56:47 am]
Is Lazarus' Tool Palette ...
by
Ed78z
[December 11, 2025, 10:37:03 am]
[SOLVED] RXSwitch
by
Petrus Vorster
[December 11, 2025, 10:35:00 am]
fpsockets error: 10047
by
rvk
[December 11, 2025, 09:50:08 am]
Military Grade Directives
by
Thaddy
[December 11, 2025, 08:56:12 am]
Permutation of rows and c...
by
Zvoni
[December 11, 2025, 08:33:20 am]
Jacks or Better card game...
by
TBMan
[December 11, 2025, 03:12:03 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Treeview memory leak (Read 3392 times)
wp
Hero Member
Posts: 13268
Treeview memory leak
«
on:
February 15, 2016, 01:24:26 am »
In the simple demo project that I posted for another topic (
http://forum.lazarus.freepascal.org/index.php/topic,31521.msg202076.html#msg202076
) heaptrc reports a bunch of memory leaks although I am pretty sure that created objects are properly destroyed.
In this demo, instances of a simple class are attached to the Data pointer of the tree nodes. The data are destroyed in the OnDeletion event of the treeview.
To check load the attachment from
http://forum.lazarus.freepascal.org/index.php/topic,31521.msg202076.html#msg202076
and enable the heaptrc option in the project options. Run, click "Add", enter some dummy data, "OK", and close the program. --> heaptrc reports more than 300 unfreed memory blocks! It is strange that none of the reported leaking lines is in my code.
Has anybody else seen this?
Logged
Blaazen
Hero Member
Posts: 3241
POKE 54296,15
Re: Treeview memory leak
«
Reply #1 on:
February 15, 2016, 01:54:59 am »
The leak doesn't come from TreeView or its data but from Form2. Adding line
Code: Pascal
[Select]
[+]
[-]
F
.
Free
;
to the end of method Unit2.CreateData resolves problem. That's because F is created without owner -> noone frees it.
Logged
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21
Try Eye-Candy Controls:
https://sourceforge.net/projects/eccontrols/files/
taazz
Hero Member
Posts: 5368
Re: Treeview memory leak
«
Reply #2 on:
February 15, 2016, 02:01:07 am »
Code: Pascal
[Select]
[+]
[-]
function
CreateData
:
TMyData
;
var
F
:
TForm2
;
begin
F
:
=
TForm2
.
Create
(
nil
)
;
try
if
F
.
ShowModal
=
mrOK
then
begin
Result
:
=
TMyData
.
Create
;
Result
.
FName
:
=
F
.
EdName
.
Text
;
Result
.
FAddress
:
=
F
.
EdAddress
.
Text
;
Result
.
FCity
:
=
F
.
EdCity
.
Text
;
Result
.
FBirthday
:
=
F
.
EdBirthday
.
Date
;
end
else
Result
:
=
nil
;
finally
F
.
Free
;
end
;
end
;
Logged
Good judgement is the result of experience … Experience is the result of bad judgement.
OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64
wp
Hero Member
Posts: 13268
Re: Treeview memory leak
«
Reply #3 on:
February 15, 2016, 10:16:57 am »
Thank you guys. I should not post code that I wrote too late at night...
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
Treeview memory leak
TinyPortal
© 2005-2018