AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Class, records and memory leaks

Ein Thema von WojTec · begonnen am 23. Jan 2013 · letzter Beitrag vom 23. Jan 2013
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Class, records and memory leaks

  Alt 23. Jan 2013, 11:15
Delphi-Version: 2010
I just bought EL7 and checked project with it. It found some memory leaks (I thought that TListView.TListItem.Data can be free automatically, but ok, I did it manually). But I have yet another leak and I don't know WTF

So, I'm adding to TListView simple class with 2 reintroduced constructors and a few record field (some record fields has another record field). On object create I only need to alloc memory and init one field (fill record with valid data) - parameter in one constructor. This record has 2 string fields and for next operations in proggy it have to valid values. To make sure record contain valid data I'm filtering input by function - it sets valid values in record, then function result is passed as constructor parameter (and second constructor doing the same, but itself internally). All is oke, hmm, it isn't oke - at the program termination EL reporting memory leaks in function that setting valid data for constructor. All in pseudocode:

Code:
button click:
 AddItem(TObj.Create(foonction(input1, input2: str))) // <-- point 1

foonction(param1, param2: str): record;
 result.param1 := extractdata1()
 result.param2 := extractdata2()

 result := formatit(result) // <-- point 2

formatit (record): record;
 do format fields strings

point 3 in EL log is in System._NewUnicodeString
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Class, records and memory leaks

  Alt 23. Jan 2013, 13:45
Alister Christie just published a new Video Tutorial for you

http://www.delphipraxis.net/172786-m...itemclass.html

Do you really think your pseudo code will give us a clue about the leaks?
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: Class, records and memory leaks

  Alt 23. Jan 2013, 14:28
Zitat:
The OnCreateItemClass event was introduced to TListView a few versions of Delphi ago, you've probably never noticed it (...)
Yes, that's true

About leaks - now I'm not sure if any are in my proggy. EL6 and EL7 in v6 mode doesn't show any, but EL7 after disable backward compatibility reporting a few kB leaked... I don't know...
  Mit Zitat antworten Zitat
Benutzerbild von Union
Union

Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.487 Beiträge
 
Delphi 7 Enterprise
 
#4

AW: Class, records and memory leaks

  Alt 23. Jan 2013, 15:03
Try to disable EL and verify the leaks with FastMM.
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz