Page 1 of 1
Free all items memory when Clear
Posted: Sat Oct 11, 2008 1:04 pm
by Sega-Zero
Hello. Adding the graphics to TRichViewEdit with AddPictureEx method. When calling Clear method, only memory for graphic is deleted. A lot of memory keeps in process memory.
For example: When I add about 5000 of graphic the process eats 250 MB, when I call the Clear method the process eats 42 MB. Even if we cut the process itself (about 2MB ) it still eats a lot of unused memory
How to totally clean up all the items memory?
Posted: Tue Oct 14, 2008 9:39 am
by Sergey Tkachenko
When you call Clear method, all memory for document and for formatting is cleared.
All pictures inserted in TRichViewEdit are freed.
I think that the tool you use to view a memory usage displays wrong values (the memory is freed by still shown as used). If you use the Task Manager, this is definitely so.
Try to minimize and restore your application after calling Clear.
Posted: Tue Oct 14, 2008 9:42 am
by Sergey Tkachenko
By the way, if you use many identical pictures, consider the following ways to reduce memory usage:
- use image lists ("bullets" and "hotspots" item types)
- duplicate pictures using Assign method rather than loading them from file each time when a new picture is needed; since Delphi implements a "copy on write" mechanism for pictures, all pictures copied by Assign method share the same graphic data.
Posted: Tue Oct 14, 2008 9:26 pm
by Sega-Zero
thanks. I use ProcessExplorer to determine memory usage. This is some kind of a mystery... If I call SetProcessWorkingSetSize with -1 parameters then memory is away. I wonder why is it happening
Posted: Wed Oct 15, 2008 6:20 am
by Sergey Tkachenko
This freed memory is still assigned to the application, because the system does not need it immediately. It will be reassigned when necessary.