Viel zu viel RAM

Für Fragen zur Programmiersprache auf welcher Lazarus aufbaut
Antworten
xedp3x
Beiträge: 15
Registriert: Mi 8. Jun 2011, 17:46

Viel zu viel RAM

Beitrag von xedp3x »

Ich habe das Problem, dass mein Programm einfach den ganzen Ram auffrisst.
Ich Empfang vor allen Pakete die Ladebalken hin und her Setzten.

Wisst Ihr woran das liegen kann?

Code: Alles auswählen

procedure TForm1.SetLevel(const id : integer; opos: String);
var
  npos : integer;
begin
  npos := StrToInt(Copy(opos,0,Pos('.',opos)-1));
 
  if id = 7 then
     lv_07.Position:= npos
  else if LLevel[id] <> nil then
     LLevel[id].Position:= npos;
end;
 
procedure TForm1.TCPReceive(aSocket: TLSocket);
var
  msg : String;
  Info: TStrings;
  dos : TStrings;
  I   : Integer;
begin
 try
  aSocket.GetMessage(msg);
  Info := nil;
  dos := Explode(msg,';');
  for i := 0 to dos.Count -1 do begin
   msg := dos[i];
   //log.d('TCP '+msg);
   if msg <> '' then begin
     info := Explode(msg,',');
     if info[0] = 'c' then begin
        chat.memo1.Lines.Add(copy(msg,3,999));
        chat.show;
     end
     else if info[0] = 'l' then
        SetLevel(StrToInt(info[1]),info[2])
     else if info[0] = '0' then
        ShowMessage(info[1])
     else if info[0] = '1' then
        SetSlider(StrToInt(info[2]),StrToInt(info[3]))
     else if info[0] = '2' then
            if info[2] <> '7' then begin
        LPanel[StrToInt(info[2])].Visible:= (info[3] <> '');
        LText[StrToInt(info[2])].Caption:=info[3];
     end;
   end;
  end;
  StatusBar1.Panels[0].Text:='Verbunden';
 
  if Info <> nil then Info.Free;
  if dos  <> nil then dos.free;
 except
   aSocket.Disconnect(true);
 end;
end;
Zuletzt geändert von Lori am Mo 9. Jan 2012, 19:55, insgesamt 1-mal geändert.
Grund: richtigen Highlighter

mse
Beiträge: 2013
Registriert: Do 16. Okt 2008, 10:22
OS, Lazarus, FPC: Linux,Windows,FreeBSD,(MSEide+MSEgui 4.6,git master FPC 3.0.4,fixes_3_0)
CPU-Target: x86,x64,ARM

Re: Viel zu viel RAM

Beitrag von mse »

-gh (heaptrace) könnte helfen das Leck zu finden.
http://www.freepascal.org/docs-html/rtl ... index.html

Martin

PS: ein mögliches Leck sind Info und dos welche im Falle einer exception im try block nicht freigegeben werden.

xedp3x
Beiträge: 15
Registriert: Mi 8. Jun 2011, 17:46

Re: Viel zu viel RAM

Beitrag von xedp3x »

Genau das war es.

Danke.

Antworten