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
Unleashed Pascal (async/a...
by
440bx
[
Today
at 12:18:31 am]
AsyncProcess not firing O...
by
Martin_fr
[August 13, 2026, 11:50:54 pm]
Clean up and build
by
n7800
[August 13, 2026, 10:15:09 pm]
How to avoid duplicates i...
by
mig-31
[August 13, 2026, 05:35:46 pm]
TDWEdit
by
docno
[August 13, 2026, 05:26:23 pm]
QGradientTrackPanel: A Fu...
by
Ed78z
[August 13, 2026, 04:49:24 pm]
Memory location
by
Thaddy
[August 13, 2026, 04:01:56 pm]
TurboBird IBX
by
laguna
[August 13, 2026, 03:55:51 pm]
Which Linux version
by
Thaddy
[August 13, 2026, 03:52:06 pm]
TlsLib4Pascal
by
Xor-el
[August 13, 2026, 03:06:13 pm]
MR - DebuggerIntf for ter...
by
Martin_fr
[August 13, 2026, 12:54:22 pm]
var vs out (including "co...
by
kupferstecher
[August 13, 2026, 12:49:22 pm]
AArch64, load a constant ...
by
LemonParty
[August 13, 2026, 12:31:06 pm]
Separators in the compone...
by
CM630
[August 13, 2026, 10:29:56 am]
Lazarus undead repository...
by
Dankan1890
[August 13, 2026, 10:28:54 am]
[RE-SOLVED] Splitting an ...
by
paweld
[August 13, 2026, 09:52:15 am]
Why does Free Pascal use ...
by
MarkMLl
[August 13, 2026, 09:30:40 am]
[Qt5/Qt6] JPSupport-Qt: J...
by
szlbz
[August 13, 2026, 03:21:56 am]
Extended and XML Frames o...
by
matthius
[August 13, 2026, 01:01:09 am]
Strangely - Not a questio...
by
Bart
[August 12, 2026, 10:26:58 pm]
Selected Text get number ...
by
Martin_fr
[August 12, 2026, 09:47:56 pm]
To DebugLn or not to Debu...
by
Martin_fr
[August 12, 2026, 09:01:02 pm]
New Big Integer library i...
by
ad1mt
[August 12, 2026, 07:16:56 pm]
The best name for procedu...
by
LemonParty
[August 12, 2026, 07:02:53 pm]
'ReadStr' ?
by
J-G
[August 12, 2026, 03:37:39 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Treeview memory leak (Read 3468 times)
wp
Hero Member
Posts: 13646
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: 13646
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