Einzelnen Beitrag anzeigen

WojTec

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

Class, records and memory leaks

  Alt 23. Jan 2013, 12: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