You are not logged in.
Pages: 1
I'm writing a simple directory to save the jewelry filtration. With the active use vyhodito error "Not enough memory to process this command", it generates a scroll pages back and forth.
I wrote a test case showing the problem. I'm on the 2950-2960 iteration pops overflow memory.
Please help solve the problem!
https://www.dropbox.com/s/zg0629isv7d7w … String.zip
TSQLProduct = class(TSQLRecord)
private
fPreview: TSQLRawBlob;
public
published
property preview: TSQLRawBlob read fPreview write fPreview;
end;
var
Form1: TForm1;
Database: TSQLRestClientURI;
Server: TSQLRestServerDB;
model: TSQLModel;
implementation
{$R *.dfm}
function CreateModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLProduct]);
end;
procedure InitClient;
begin
Model := CreateModel;
Database := TSQLRestClientDB.Create(Model, CreateModel, 'test.db3', TSQLRestServerDB);
if Database = nil then Exit;
DataBase.ForceBlobTransfert := True;
TSQLRestClientDB(Database).Server.CreateMissingTables(0);
end;
procedure FinalizeClient;
begin
Server.Free;
Database.Free;
Model.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, j, c: Integer;
jpg: TJPEGImage;
pic: RawByteString;
prd: TSQLProduct;
begin
c := 0;
for j := 1 to 1000 do begin
for i := 1 to 1000 do begin
prd := TSQLProduct.Create(Database, i, False);
try
pic := prd.preview;
inc(c);
Caption := IntToStr(c);
if pic <> '' then begin
img.Picture := nil;
img.Picture.Assign(LoadFromRawByteString(pic));
end;
finally
FreeAndNil(prd);
end;
Application.ProcessMessages
end;
end;
end;
initialization
Gdip := TGDIPlusFull.Create;
InitClient;
finalization
FinalizeClient();
end.
Last edited by proto (2014-08-06 09:04:36)
Offline
I suppose your picture is internal loop is never released.
Perhaps you should better write:
img.Picture.Free;
img.Picture := nil;
Or use a local variable, with a try..finally block.
Offline
is not the problem if you comment out these lines, the error is still there.
if pic <> '' then begin
// img.Picture := nil;
// img.Picture.Assign(LoadFromRawByteString(pic));
LoadFromRawByteString(pic)
end;
error somewhere in the bowels function LoadFromRawByteString
Last edited by proto (2014-08-06 09:24:50)
Offline
LoadFromRawByteString() returns a new TBitmap class instance which is never released by your loop!
The problem is not in LoadFromRawByteString() but in how you use it!
I suppose that if you write:
LoadFromRawByteString(pic).Free;
there won't be any leak any more.
Offline
thank you very much for your help, this is true, there are no memory leaks
Offline
Pages: 1