From a beginners point:
I have difficulties with access errors and memory leaks when closing application with TRV (ver9) + table + dynamic generated images.
Images are created on demand like:
Timage(picarray):=Timage.create ....
picarray.loadfromfile(filelist).....
table.cells[x,y].addpicturex(picarray,......)
printthisRVdocument()
rv.rvdata.clear; //should delete all items and free memory
setlength(picarray,0);
Now, when closing the application memcheck will show a lot of errors. They disappear of I do not generate rv documents. Any ideas how to make this water proof and exclude memory leak errors?
Memory leak
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You call AddPictureEx(... picarray.Picture.Graphic, ...)
TRichView will delete picarray.Picture.Graphic, but picarray will not be deleted.
Is it necessary to create array of TImages?
For example, you can use grarray: array of TGraphic instead of picarray.
So the code will be
This is about memory leaks. As for AV errors, may be you add the same picture more than one time, so it is freed several time?
TRichView will delete picarray.Picture.Graphic, but picarray will not be deleted.
Is it necessary to create array of TImages?
For example, you can use grarray: array of TGraphic instead of picarray.
So the code will be
Code: Select all
var pic: TPicture;
pic := TPicture.Create;
pic.LoadFromFile(filelist[i]);
grarray[i] := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
grarray[i].Assign(pic.Graphic);
pic.Free;
table.cells[x,y].addpicturex(grarray[i],......)
printthisRVdocument()
rv.Clear;
setlength(grarray,0);
memory leaking
TRichView will delete picarray.Picture.Graphic, but picarray will not be deleted.
Yes, I think this can be the cause of my problem!
This is about memory leaks. As for AV errors, may be you add the same picture more than one time, so it is freed several time?
Such mistakes - I found - are easier to trace and to correct than memory leak errors.
Great support, great component!