Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

Tpicture.LoadFromFile leaking memory under linux/gtk2?

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

I'm not sure it is a bug, so I'm asking here before reporting it as such.

this code:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
   timer1.enabled:=false;
   while not Application.Terminated do
   begin
     image1.Picture.loadfromfile('test.png');
     Label1.Tag:=Label1.Tag+1;
     Label1.Caption:=IntToStr(Label1.Tag);
     Application.ProcessMessages;
   end;
end;

works perfectly under windows, but under linux/gtk2 the application is using more and more memory (slowly but constantly, until the OOM kills it) both for the application itself and for X.
Of course heaptrc reports no leak, using cmem doesn't help.

Before you ask, the application is not an interactive one, and the above construct is to avoid using a thread (which makes memory usage even worse), the real loop is like "read some data from the network, display it, application.processmessages". If I limit myself to update labels, memory usage stays constant, as soon as I try to use images (like the above example) memory usage starts growing.

This happened both with an old svn revision (22350) with fpc 2.2.4 and with a version updated yesterday (27607) with fpc 2.4.0.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

En/na Luca Olivetti ha escrit:

Show quoted text 30 lines
I'm not sure it is a bug, so I'm asking here before reporting it as such. this code: procedure TForm1.Timer1Timer(Sender: TObject); begin timer1.enabled:=false; while not Application.Terminated do begin image1.Picture.loadfromfile('test.png'); Label1.Tag:=Label1.Tag+1; Label1.Caption:=IntToStr(Label1.Tag); Application.ProcessMessages; end; end; works perfectly under windows, but under linux/gtk2 the application is using more and more memory (slowly but constantly, until the OOM kills it) both for the application itself and for X. Of course heaptrc reports no leak, using cmem doesn't help. Before you ask, the application is not an interactive one, and the above construct is to avoid using a thread (which makes memory usage even worse), the real loop is like "read some data from the network, display it, application.processmessages". If I limit myself to update labels, memory usage stays constant, as soon as I try to use images (like the above example) memory usage starts growing. This happened both with an old svn revision (22350) with fpc 2.2.4 and with a version updated yesterday (27607) with fpc 2.4.0.

I worked around the problem by caching the images in memory instead of loading them every time, but I'd like to know where the above is leaking memory.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email