Group: Forum Members
Last Active: 3 Years Ago
Posts: 7,
Visits: 70
|
Gents,
I ran into the same "Out of Memory" issue using the compiled application ("Nevron.Examples.Diagram.WinForm.exe") that is distributed with version 2015.1.
I attempted to load a 4 mb jpeg image into a rectangle and also into the background without success. However, the same image loads into "Paint" and other apps.
Smaller images load correctly but require the end user to reduce the image size is onerous.
Any suggestions?
Regards,
Allen K
|
Group: Forum Members
Last Active: 11 Years Ago
Posts: 7,
Visits: 1
|
Hey Brian, thanks for the suggestions. The code above is just a simplified example, we do allow for a much larger amount of images so cannot simply store them in memory and swap between them.
However, I just got a Message from Nevron support that they have just uploaded a new SP which fixes the memory leak issue (build version: 13.4.2.12).
|
Group: Forum Members
Last Active: 11 Years Ago
Posts: 1,
Visits: 1
|
We've run into the same sort of OutOfMemoryExceptions when using large images... in our case, inside objects rather than as the background. Here's our analysis so far:
(1) Nevron doesn't seem to be designed to handle normal-size bitmaps... the only apparent mechanism appears to be designed for tiny bitmaps used as Brush textures. So (I say this reluctantly since we've invested a lot in Nevron-based code), it may not be the right library if you need to use normal-size photographs in the diagrams.
(2) Based on examining what's produced in a Memory Profiler, it appears that creating an NImageFillStyle from a Bitmap creates a copy of that Bitmap from which it builds a new Brush... and it puts that Bitmap-Brush pair into an internal Hashtable. Those never get removed.
(3) The View and the Zoom Preview each seem to end up with their own Bitmap objects... painted using the Brush, we presume... so, probably separate Bitmaps. Those do seem to go away when you make changes.
One question we had was whether that Hashtable is testing the key Bitmaps by-reference or by-value. Given you are having trouble with that code, the answer must be by-reference.
Based on that analysis, since you are always setting the background to either nothing, the male pic, or the female pic, a possible solution for you is to create the two Bitmaps, create two NImageFillStyles from those, and never Dispose and reload any of those. Then just swap between the different NImageFillStyles... so, presumably Nevron will then find the matching Brush rather than rebuild it, and then reuse those elements rather than accumulating new ones.
Another thing you should do is make sure that the .png and the .jpg images are only as high resolution as you need on-screen... because the Bitmaps' sizes will be dictated by the uncompressed pixel array it generates (the resolution of those files, not the megabytes of those files).
Please let us know if that works for you... it won't solve our problem, but it will close some knowledge gaps in our analysis. Hope that helps.
|
Group: Forum Members
Last Active: 11 Years Ago
Posts: 7,
Visits: 1
|
I use the following function below to toggle between having a background image of a man or a woman for making indications of Medical symptoms. When toggling back and forth a few times, I am getting OutOfMemoryExeptions when trying to execute the codeline that creates a new BitMap.
I have done what I can to Dispose and restrict memory leaks, but it seems it is out of my hands. Is there any other way to prevent this from happening or does Nevron Diagram not have the ability to handle large images as background Pictures?
public void SetGender() { if (backgroundBMP != null) backgroundBMP.Dispose(); NDrawingDocument1.BackgroundStyle.FillStyle.Dispose(); NDrawingDocument1.Dispose(); GC.Collect();
NDrawingDocument1 = new NDrawingDocument(); NDrawingView1.Document = NDrawingDocument1;
if (nRadioButton1.Checked) backgroundBMP = new Bitmap("c:\\temp\\hiresmale.png"); else backgroundBMP = new Bitmap("c:\\temp\\woman4000.jpg");
NDrawingDocument1.BackgroundStyle.FillStyle = new NImageFillStyle(backgroundBMP); RefreshView(); }
|