|
|
Re: Need I destroy the image created for a draw2d figure?and Where? [message #237314 is a reply to message #237290] |
Mon, 30 July 2007 09:43 |
David BY Chan Messages: 40 Registered: July 2009 |
Member |
|
|
Alex Boyko wrote:
> Hi,
>
> There is an editpart associated with a figure, hence you can dispose
> your image in #deacivate method of the editpart. Since, usually image is
> cached on the figure, if image gets updated you need to dispose the old
> one before creating creating the new one.
> Hope this helps.
>
> Cheers,
> Alex
>
Thanks you Alex, I selected the most foolish way to solve this problem,
that is, to create a help class ResourceManager to manage some resource
that can't be collected by GC for EditorPart, which includes the method
dispose.
The class ResourceManager is used to cache the resource needed by Figure
such as image, font and color, it also contains a method dispose to
destroy any resource when the EditorPart's method 'dispose' be invoked.
If I put the Create-Destroy process in the methods 'activate' and
'deactivate', there are two disadvantages:
1. Create-Destroy is a little more frequent, need more CPU calculations
2. Can't be reused if two figures need the same image or resource.
Thanks again!
|
|
|
Powered by
FUDForum. Page generated in 0.03514 seconds