Free all items memory when Clear

General TRichView support forum. Please post your questions here
Post Reply
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Free all items memory when Clear

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply