Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Spring4D IList memory overflow

I am using IList from the excellent Delphi framework Spring4D by Stefan Glienke.

I have a list IList and I refill this list many times during my application is run. So, after two or three hours I have a memory overflow of my list.

This is how I populate my list:

  list := TCollections.CreateList<TVisitor>;

  for i := 0 to dataSet.RecordCount - 1 do begin
        item := TVisitor.Create ();

        item.Surname := dataSet.FieldByName ( 'firstname' ).AsString;
        item.Name := dataSet.FieldByName ( 'secondname' ).AsString;
        item.Patronymic := dataSet.FieldByName ( 'thirdname' ).AsString;
        item.CardNumber := dataSet.FieldByName ( 'cardnumber' ).AsString;

        list.Add ( item );

        dataSet.Next ();
  end;

The Clear() method doesn't free a memory, so each time I fill my list the Windows Task Manager inc memory usage of my application :(

like image 405
Aptem Avatar asked Jul 22 '15 09:07

Aptem


1 Answers

Your list does not free the TVisitor instances.

Create is like this:

TCollections.CreateList<TVisitor>(True);
like image 120
Stefan Glienke Avatar answered Oct 22 '22 16:10

Stefan Glienke