Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » AbstractTransparentImage keeps the bitmap of the image in memory
AbstractTransparentImage keeps the bitmap of the image in memory [message #1844134] Thu, 02 September 2021 12:22 Go to next message
Yann Mortier is currently offline Yann MortierFriend
Messages: 19
Registered: July 2009
Location: Paris FR
Junior Member
Hi,

I have discovered that Sirius keeps a bitmap of the image set on a Node in memory. The class org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.AbstractTransparentImage has a field imageData that is the bitmap of the image set on the node. This field is kept in memory to avoid too many invocations to Image.getImageData when Sirius tries to find the first opaque pixel when computing source and target anchors (see org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.util.OpaquePixelFinder)

It is problematic when the end user uses images with very high resolution. There are many potential optimizations:



  1. Sharing the cached ImageData between all instances of AbstractTransparentImage which use the same Image.
  2. Keeping the image data only when source or target anchor position is computed.
  3. Using a BitSet or a boolean array representing the alpha pixels instead of the whole bitmaps.
  4. Downsizing the cache to the real size of the image on the diagram (but this cache must be invalidated as soon as the user resizes the image).
  5. Instructing the user to not use images with high resolution


The attached Ecore Modeling Project allows to reproduce the problem. If you open the only one diagram and capture an heapdump, you can see that the bigger objects are the bitmaps kept in memory.
The attached screenshot of VisualVM highlights the issue.

The sample diagram has only 7 classes but the bitmaps (instances of ImageData) weight more than 200Mo.

Should I open an issue on the bugzilla?

Have a nice day,
Yann
Re: AbstractTransparentImage keeps the bitmap of the image in memory [message #1844261 is a reply to message #1844134] Tue, 07 September 2021 10:00 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi Yann!

Yes, please open a bugzilla. A patch on Gerrit would be even better :)
At first glance, optimizations 1 + 3 look like they could improve the situation without adding too much complexity in terms of data lifecycle, but I have only taken a quick glance at the code.



Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: AbstractTransparentImage keeps the bitmap of the image in memory [message #1844406 is a reply to message #1844261] Mon, 13 September 2021 09:28 Go to previous message
Yann Mortier is currently offline Yann MortierFriend
Messages: 19
Registered: July 2009
Location: Paris FR
Junior Member
Hi Pierre-Charles

I hope you are well!

Thank you for the answer. I think I can come up with a patch using a BitSet, this will almost divide the memory consumption by 24 for images that use 3 bytes for each pixel. Delaying the computation of the BitSet on the first call of AbstractTransparentImage.getImageAlphaValue (int, int) can also provide benefits to nodes that have a border or do not have source / target edges.

Sharing the BitSet for all figures is more tricky and I don't know how to do it without another global map. The obvious candidate for keys is ImageDescriptor but the values should be WeakReferences to not retain BitSets instances into memory.

So, I will try to replace the ImageData with a BitSet and I will provide some measurements.

Have a nice day,
Yann
Previous Topic:Sirius web - how to download/upload models
Next Topic:the function [Export representations as images]of arid file
Goto Forum:
  


Current Time: Wed Apr 24 16:35:10 GMT 2024

Powered by FUDForum. Page generated in 0.03137 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top