|T O P I C R E V I E W
||Posted - 27 Sep 2016 : 03:34:32
I have an out of memory exception using QCCHart2DNET.
The application continues to run, the memory used by the application is very low, there is no saturation, only the Chart object looks to be out of memory and a red cross takes place on the chart. There are not really a lot of data to display. The issue happened after a few days, the chart is used about 10 minutes, the object is disposed and then the chart is restarted with the new process a few minutes later, etc...
Please, what I can do to solve this issue ?
This is the exception message :
************** Exception Text **************
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at com.quinncurtis.chart2dnet.DoubleArray..ctor(Int32 n)
at com.quinncurtis.chart2dnet.SimpleDataset.InitDatasetBase(String sname, Int32 n)
at com.quinncurtis.chart2dnet.SimpleDataset..ctor(String sname, Double x, Double y, Boolean valid, Int32 n)
at com.quinncurtis.chart2dnet.SimpleDataset.GetFastClipDataset(String s, PhysicalCoordinates transform, Int32 fastclipmode, Int32& fastclipoffset)
at com.quinncurtis.chart2dnet.SimpleLinePlot.DrawLinePlot(Graphics g2, GraphicsPath path)
at com.quinncurtis.chart2dnet.SimpleLinePlot.Draw(Graphics g2)
at com.quinncurtis.rtgraphnet.RTSimpleSingleValuePlot.Draw(Graphics g2)
at com.quinncurtis.chart2dnet.ChartView.DrawObject(Graphics g2, GraphObj graphobject1, Rectangle2D viewrect)
at com.quinncurtis.chart2dnet.ChartView.Draw(Graphics g2)
at com.quinncurtis.chart2dnet.ChartView.OnPaint(PaintEventArgs pe)
|11 L A T E S T R E P L I E S (Newest First)
||Posted - 28 May 2017 : 14:56:30
My program works in this manner:
- the user launchs the program and selects a cycle of swith-on and switch-off of some loads connected to equipment.
- when all parameters are setted, program goes on and reads some currents and voltages. These values are recorded and immediatly visualized through a single and unique instance of RTAutoScrollGraph obtained with a user control positionated on a windows form. When this form is loaded it calls the InitializeGraph() of user control, that is modified with my personalizations (and now adding the AutoTruncateDataset, MinimumValue and MaximumValue).
- if program runs for a small time there isn't problem, but if it works for 1-2-3 weeks, the error happens.
Then there aren't more object instances, but only one that is the same from start to end.
Now, I'm modifiying the program with your suggestions and I need some weeks to test it.
||Posted - 27 May 2017 : 18:08:53
What are you doing to create a new graph each time? Are you instantiating a new RTAutoScrollGraph control and then add it to the window. If so, do you remove the previous one from the window and make sure you don't have any references to it hanging around in global memory?
Or, are you using the same instance of an RTAutoScrollGraph for each new graph, and not instantiating a new one each time?
If you cannot solve the problem you will need to supply us with a simple example of exactly what you are doing, ie. what is different from what our demos programs do.
||Posted - 27 May 2017 : 10:51:40
ok for my second problem, probably i made some error if in your sample code you visualize also just one point.....
For now I'll modify my code that use RTAutoScrollGraph with AutoTruncateDataset, after I'll study better your low level code to implement my own scrolling graphics.
In my first problem, window is never destroyed. It live from begin to the end of program. I'll go to implement also the .net garbage collection and we'll see what happen.
Have a good day
||Posted - 26 May 2017 : 18:27:37
Sorry but we cannot reproduce what you describe in your second question. Our RTAutoScrollGraph example, (the first screen) found in AutoGraphDemos, starts by displaying a single point and adds a point at a time. So, if you cannot resolve the problem by studying that demo, you will need to supply us with the simplest possible example project which reproduces the problem.
Since you using RTAutoScrollGraph, you do not create RTProcessVar objects as in all of our other examples. If you want access to the RTProcessVar objects internal to the RTAutoScrollGraph control, in order to se the AutoTruncateDataset flag, use code similar to below.
// this code adds three plots to the scroll graph
rtAutoScrollGraph1.InitSimpleRTPlotObject(ChartObj.LINE_PLOT, Color.Blue, "Channel #1");
rtAutoScrollGraph1.InitSimpleRTPlotObject(ChartObj.LINE_PLOT, Color.Green, "Channel #2");
rtAutoScrollGraph1.InitSimpleRTPlotObject(ChartObj.SCATTER_PLOT, Color.Red, "Channel #3");
// this code sets the AutoTruncateDataset for the three internal RTProcessVar objects
rtAutoScrollGraph1.GetProcessVariable(0).AutoTruncateDataset = true;
rtAutoScrollGraph1.GetProcessVariable(1).AutoTruncateDataset = true;
rtAutoScrollGraph1.GetProcessVariable(2).AutoTruncateDataset = true;
Are you creating a new window each time and recreating all of the scrolling graphs? Are your old windows being disposed of? If not, then all of our objects in those windows will also not be disposed of when garbage collection is called.
You might look into just creating your scrolling graphics using our low level routines, as demoed in the ScrollApplication1 example. Over the years, almost no one that we know of has used the RTAutoScrollGraph control. You will have infinitely more control over the look of your chart if you use the low level routines instead of RTAutoScrollGraph control.
||Posted - 26 May 2017 : 14:19:13
first of all thank you for reply.
Then I'll try to implement your suggestion about my first problem and I let you know.
Regarding the second problem do you have some suggestions?
||Posted - 25 May 2017 : 18:45:19
First, nothing prevents you from calling GC.Collect. Go ahead and call it periodically; each time you make a new chart. It will force a garbage collection of all memory no longer used. Sometimes .Net just doesn't release the memory, probably because it off doing other things.
Also, make sure you set the AutoTruncateDataset property of all of the RTProcessVar objects your are using to True.
Use the RTProcessVar AutoTruncateDataset, AutoTruncateMinCount, and AutoTruncateMaxCount properties. When the scroll buffer reaches the AutoTruncateMaxCount value, it deletes the oldest data points until there are only AutoTruncateMinCount values in the buffer.
RTProcessVar EngineRPM1 = new RTProcessVar("RPM", defaultattrib);
EngineCylinders1.AutoTruncateDataset = true;
// keep at least 10000 samples in memory.
EngineCylinders1.AutoTruncateMinCount = 10000;
// truncate data to 10000 when a count of 20000 samples is reached.
EngineCylinders1.AutoTruncateMaxCount = 20000;
Once you set these properties, you don't have to do anything else, the data will be truncated automatically.
||Posted - 25 May 2017 : 14:27:13
Just a precisation respect my first problem: i don't dispose the graph during the acquisition, so i can't use the garbage collection..... i think.....
||Posted - 25 May 2017 : 14:16:51
i have two problems with RTAutoScrollGraph:
1) This problem is similar to that of NicoG. Software generate this error:
System.OutOfMemoryException: Generata eccezione di tipo 'System.OutOfMemoryException'.
in com.quinncurtis.chart2dnet.DoubleArray.ResizeCapacity(Int32 newcapacity)
in com.quinncurtis.chart2dnet.DoubleArray.SetLength(Int32 newlength)
in com.quinncurtis.chart2dnet.DoubleArray.Add(Double r)
in com.quinncurtis.chart2dnet.SimpleDataset.AddDataPoint(Double x, Double y)
in com.quinncurtis.rtgraphnet.RTProcessVar.UpdateDataset(Double timestamp, Double pv, Boolean goodvalue)
in com.quinncurtis.rtgraphnet.RTProcessVar.SetCurrentValue(Double timestamp, Double pv)
in com.quinncurtis.rtgraphnet.RTAutoScrollGraph.UpdateScrollGraph(Double timestamp, Double values, Boolean updatedraw)
in MPC.ctrlUtGrafici.tmrVisualizzaDatiInGrafico_Tick(Object sender, EventArgs e)
in System.Windows.Forms.Timer.OnTick(EventArgs e)
in System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The application (written in Visual basic .Net 2008) visualize data taken from an hardware datalogger. For short time the problem don't happen, but after for example 1 week or more, it happen.
Visualization is called by a timer. I put data in dataset
Private sub subTimer_tck()
Static theTimeGo As Double
For intCounter = 0 To 10
ValuesToShow(intIndice) = pdblVoltageCHx(intCounter)
intIndice += 1
Me.UpdateScrollGraph(theTimeGo, ValuesToShow, True)
what can i do to avoid the problem?
2) In another application i have to visualize other data always with a RTAutoScrollGraph. Data are taken by a data file. I noticed that visualization don't begin if in dataset there aren't a big quantity of values. Instead i want to visualize even a single value.
The code is similar to the code above
Thank you in advance
||Posted - 27 Sep 2016 : 10:48:12
OK, we sent you the link.
The current version of the software is still compatible with VS 2008 and .Net 2.0.
||Posted - 27 Sep 2016 : 10:17:16
Thank you for your reply.
I will try to force the garbage collector and I keep you posted.
I'm using QCRTGraphNet.dll and QCChart2DNet.dll in version 184.108.40.206 but I'm still using the framework 2.0 with VB.NET 2008. Is your last version 2.3 compatible ?
Yes, I would like the link to download, please.
||Posted - 27 Sep 2016 : 08:28:46
You can try forcing the .net garbage collection, after each time you dispose the chart, using the .net GC.Collect method.
The automatic .Net garbage collection can be unreliable.
What revision of the QCChart2D for .Net software are you using? If you are using an old version, you should upgrade to the current version of 2.3. You can do that using the original download link you were sent at the time of the purchase. If you don't have that link, we can send it to you again.