Memory Leak. Missing 64 blocks lazarus / 21-General ---------------------------------------------------------------------- BlueIcaro · 2023-01-31 09:38 Hello, I have the following code: Code: [Select]var   Cadena, NombrePropiedad: string;   J, I: integer;   PP: PPropList;   PPI: Pointer;   PT: PTypeData;   TipoPropiedad: TTypeKind;   b: boolean; begin   Cadena := '';   PPI := aItem.ClassInfo;   PT := GetTypeData(PPI);   GetMem(PP, PT^.PropCount * SizeOf(PP));   J := GetPropList(aItem.ClassType, PP);   //for I := 0 to J - 1 do   //begin   //  with PP^[I]^ do   //  begin   //    NombrePropiedad := Name;   //  end;   //  TipoPropiedad := PropType(aItem, NombrePropiedad);   //  case TipoPropiedad of   //    tkAString:   //    begin   //      Cadena := GetStrProp(aItem, NombrePropiedad);   //      if Cadena <> '' then   //      begin   //        Cadena := Format('-%s "%s"', [NombrePropiedad, Cadena]);   //        aLineas.Add(Cadena);   //      end;   //    end;   //    tkBool:   //    begin   //      B := GetPropValue(aItem, NombrePropiedad);   //      if b then   //      begin   //        Cadena := Format('-%s ', [NombrePropiedad]);   //        aLineas.Add(Cadena);   //      end;   //    end;   //  end;   //end;   Freememory(PP, PT^.PropCount * SizeOf(PP));                                      As you can see I comment many code, but I couln't find where is the leak memory. Any idea Thanks in advance /BlueIcaro ---------------------------------------------------------------------- Thaddy · 2023-01-31 09:41 It is FreeMem, NOT FreeMemory. ---------------------------------------------------------------------- balazsszekely · 2023-01-31 10:08 @Thaddy Freememory is just an alias for FreeMem. @BlueIcaro Your leak originates from Button2Click. Can you post the code? Even better a small demo that shows the issue would be nice. ---------------------------------------------------------------------- BlueIcaro · 2023-01-31 10:16 Quote from: GetMem on January 31, 2023, 11:08:34 am@Thaddy Freememory is just an alias for FreeMem. @BlueIcaro Your leak originates from Button2Click. Can you post the code? Even better a small demo that shows the issue would be nice. With Freemem I got the same problem because is the same instruccion as you say GetMem Here is the buttonClick2 Code: Code: [Select]procedure TForm1.Button2Click(Sender: TObject); var   E: TCrossConexionList;   Lista, L: TStringList;   I: integer; begin   if OpenDialog1.Execute then   begin     Lista := TStringList.Create;     Lista.LoadFromFile(OpenDialog1.FileName);     E := TCrossConexionList.Create;     E.LoadFromStrings(Lista);     Memo1.Lines.Clear;     L := E[0].GenerateLines;     FreeAndNil(L);     FreeAndNil(Lista);     FreeAndNil(E);   end; end; Also a attach all project. /BlueIcaro ---------------------------------------------------------------------- howardpc · 2023-01-31 10:18 Try code such as this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.ShowItemInfo(aItem: TComponent; aLineas: TMemo);var  Cadena, NombrePropiedad: String;  propCount, i: Integer;  PropListPtr: PPropList;  TipoPropiedad: TTypeKind; begin  Cadena := '';  propCount := GetPropList(aItem.ClassType, PropListPtr);  if propCount > 0 then  try    for i := 0 to propCount - 1 do      begin        NombrePropiedad := PropListPtr^[I]^.Name;        TipoPropiedad := PropType(aItem, NombrePropiedad);        case TipoPropiedad of        tkAString: begin                        Cadena := GetStrProp(aItem, NombrePropiedad);                        if Cadena <> '' then                        aLineas.Lines.Add('-%s "%s"', [NombrePropiedad, Cadena]);                      end;          tkBool: if {%H-}GetPropValue(aItem, NombrePropiedad) then                    aLineas.Lines.Add('-%s ', [NombrePropiedad]);        end;      end;  finally      Freemem(PropListPtr);    end;end;You don't need an explicit GetMem, since the call to GetPropList allocates the memory required. ---------------------------------------------------------------------- Thaddy · 2023-01-31 13:29 Indeed. It is also the cause of the leak. ---------------------------------------------------------------------- BlueIcaro · 2023-02-01 07:46 Thanks howardPC, now I don't have a memory Leak. By the way the original code is from pascal help file. May be should be update https://www.freepascal.org/docs-html/rtl/typinfo/getproplist.html /BlueIcaro