OutOfMemoryException

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

OutOfMemoryException

Post by paultobey » Fri Mar 14, 2014 2:18 am

Hi,

I've been chasing an out-of-memory exception in my LightningChartUltimate-based WPF application for some time. I think I've identified the root cause: AnnotationXY and images:

// Don't fill the annotation. Just show the graphic.
annotation.Fill.Style = RectFillStyle.Bitmap;
annotation.Fill.Bitmap.Image = customImage;

annotation.Fill.Bitmap.ImageAlpha = 0xff; // Not transparent.
annotation.Fill.Bitmap.Layout = BitmapFillLayout.Center;

I use such annotations to display "program start times" on a sensor data graph. Sensor data might span several years with several hundred points per day but no more than 1 such annotation per day per sensor. Maximum sensors per chart is 14. 3 charts active at a time.

customImage is a BitmapFrame, of course, 16x16x32-bit. I think that you are creating an Image instance for each such annotation and that the 14 (sensors) * 720 (days, for example) * 1 (bitmap/day) * 3 (active charts in the application at a time) is responsible for the memory issue. Any chance you'd add a version of the AnnotationXY to take an actual Image instance, rather than a BitmapFrame? Since my annotations use the same Image this change would reduce my Image count to...1 from 30240.

Please?
Paul T.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: OutOfMemoryException

Post by ArctionPasi » Fri Mar 14, 2014 8:06 pm

That's a lot of bitmaps there...

Same BitmapFrame you can assign for all of them and that part is shared. LightningChart creates a DirectX texture for every annotation, and eats the memory apparently. Making a duplicate checking dictionary/cache inside LightningChart should remove the problem, but programming it and handling the texture disposing is not unfortunately a thing that we can program quickly. :|
LightningChart Support Team, PT

paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

Re: OutOfMemoryException

Post by paultobey » Fri Mar 14, 2014 8:16 pm

Yes, the same BitmapFrame is passed for creation of all annotations but it does appear to be during your processing that the OutOfMemoryException is fired.

You don't have an Image cache that you can just drop in? ;)

I'll try to convince my QA guys to defer the defect but they could hold product release.

Paul T.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: OutOfMemoryException

Post by ArctionPasi » Mon Mar 17, 2014 7:18 am

Hi Paul,

unfortunately we can't take this in LightningChart agenda right now.

Please try an approach where you set
Annotions.Fill.Bitmap = Annotations[0].Fill.Bitmap.

as a general design guideline, we have to say don't do it like this (don't share the objects) but here it might work.
LightningChart Support Team, PT

paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

Re: OutOfMemoryException

Post by paultobey » Mon Mar 17, 2014 5:23 pm

This work-around is acceptable for now.

Unfortunately with every fixed issue there's another question. On such a dense chart, I'm seeing black areas as though the chart pixels under the bitmap are being blacked out. Here's a section of a chart with many overlapping bitmaps:
DenseAnnotations.png
DenseAnnotations.png (13.13 KiB) Viewed 10440 times
The image comes from a PNG file 16x16 with transparent pixels around the outside. I don't see any image changes on my end that would affect this. I've attached the image in case it helps.

Paul T.
Attachments
The annotation icon, 16x16.
The annotation icon, 16x16.
clock_go.png (965 Bytes) Viewed 10440 times

paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

Re: OutOfMemoryException

Post by paultobey » Mon Mar 17, 2014 6:03 pm

Never mind. I thought that borders and shadows were off, but they were not. All is well. :oops:
Paul T.

Post Reply