10-31-2011 07:34 AM
Hello
I have an application that is readings and plotting 16channels of temperature data on a scattergraph. After a day or so of recording/displaying the data the system crashes and gives the following error box. It also turns the graph into a white box with a red "X" through it. I have an update rate of 1sample/30seconds and was attempting to record for 15 days.
Why does the NI Scattergraph (16 scatterplots) crash consistantly with this error? How can I get past this issue? Thanks for your help.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Collections.Generic.List`1.set_Capacity(Int32 value)
at System.Collections.Generic.List`1.EnsureCapacity(Int32 min)
at System.Collections.Generic.List`1.Add(T item)
at NationalInstruments.UI.Internal.XYDeviceDataManager.XYDeviceDataProviderSpecialValues.GetPoints(PointF[] points)
at NationalInstruments.UI.Internal.XYDeviceDataManager.XYDeviceDataProviderSpecialValues.GetLines(PointF[] points, LineStepInternal lineStep)
at NationalInstruments.UI.Internal.ScatterDeviceDataManager.GetLines(PointF[] points, Int32[] clippedDataIndices)
at NationalInstruments.UI.Internal.XYDeviceDataManager.Map(Domain fromXDomain, Domain fromYDomain, Rectangle bounds, Boolean invertedX, Boolean invertedY, PointF[]& mappedData)
at NationalInstruments.UI.Internal.CartesianPlotElement.Map(Rectangle bounds, PointF[]& mappedData)
at NationalInstruments.UI.Internal.CartesianPlotElement.DrawPlot(ComponentDrawArgsInternal args)
at NationalInstruments.UI.Internal.PlotElement.DrawForeground(ComponentDrawArgsInternal args)
at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
at NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)
at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
at NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)
at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
at NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)
at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1)
at NationalInstruments.Restricted.ControlElement.Paint(PaintEventArgs e)
at NationalInstruments.UI.WindowsForms.ControlBase.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
10-31-2011 05:06 PM - edited 10-31-2011 05:10 PM
What do you have your Plot History Capacity set to? If I did the math correctly, then 15 days worth of data will be almost 700,000 data points. This could be a bit too much data to be represented on the graph. The data points may only take a few bytes each, but when you are graphing them, there is more information being stored in the graph. Try setting your history capacity to something much smaller. Usually when you need to record this much data, you will have to do it using a file. Try using the TDMS library to record the data in a TDMS format.
11-02-2011 04:54 PM
Yes I am also writing them line by line to a file for later viewing. And I know that pixel size means I cant view all the points on the screen but they still take memory, but its easy to zoom if I just plot all the points.
What is the max the scatterplot history can be. I have the 16 plots set to 100,000 history now and it still gives an error occassionally, although not nearly as often.
I have read something about it could be caused by a thread issue or something? I'm using VB.net 2010 and am not setting up threads in my application at all so its the default for a VB project.
11-04-2011 09:51 AM
I ran a test similar to what you described of your application. I tracked the memory usage overnight and did not see any spikes. In fact the application was using less memory when I got here this morning than it was when I left last night.
Is there anyway you could send me a small application that reproduces this? Or if not that, a snippet of your code that the error is coming from.
11-04-2011 02:27 PM
At one time I sent NI my entire application and they were running it but could not duplicate the error. I run it here on production machines (multiple pc's) and they all intermittantly do it.
I will see if I can come up with something as a test case.
perhaps you could generate random data at 1second update and plot it with a scatterplot on 16 channels and let it run until it bombs out. Set the history capacity to something large on all 16 channels like 1000000. simply wait and watch. Do not let the data roll and drop old data as new data is APPENDED to the plot continuously.
Matt
11-04-2011 02:53 PM
I thought that is what I did last night, but on second inspection, I actually had the wrong history length. Let me run this test again tonight.
11-04-2011 02:55 PM
also when you do that check your task manager and you will see some large amount of memory for the program ~500MB but if you minimize the graph once and bring it back up it drops to like ~30MB and stays there until it eventually starts to ramp up again.
Thanks for testing.
11-04-2011 03:17 PM
That is probably because of the non-deterministic behavior of the garbage collector in .NET. You can use gc.collect() to force the garbage collector to run periodically. Since you are only sampling at 0.5 Hz, you could just collect after drawing every sample.
11-14-2011 07:46 AM
I let the program run over the weekend and it still crashed with the big red "X" on the screen. I had the capacity set to 300000 for each of the 16channels.
I added some GC.COLLECT() at key places in the program and it didnt seem to make much difference.
Thanks
11-14-2011 11:53 AM
I still can't manage to reproduce this on my system. Is there anyway you could create an example application that reproduces this on your system?