Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net
 Real-Time Graphics Tools for .Net (VB and C#)
 Out of memory exception
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

NicoG

France
12 Posts

Posted - 27 Sep 2016 :  03:34:32  Show Profile  Reply with Quote
Good morning,

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 ?
Thanks

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)

quinncurtis

1586 Posts

Posted - 27 Sep 2016 :  08:28:46  Show Profile  Reply with Quote
You can try forcing the .net garbage collection, after each time you dispose the chart, using the .net GC.Collect method.

GC.Collect();

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.
Go to Top of Page

NicoG

France
12 Posts

Posted - 27 Sep 2016 :  10:17:16  Show Profile  Reply with Quote
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 1.7.1.4 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.
Go to Top of Page

quinncurtis

1586 Posts

Posted - 27 Sep 2016 :  10:48:12  Show Profile  Reply with Quote
OK, we sent you the link.

The current version of the software is still compatible with VS 2008 and .Net 2.0.
Go to Top of Page

mvelettronica

Italy
5 Posts

Posted - 25 May 2017 :  14:16:51  Show Profile  Reply with Quote
Hello,
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.VisualizzaDatiGrafico()
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
Next
theTimeGo +=1
Me.UpdateScrollGraph(theTimeGo, ValuesToShow, True)
end sub

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

Any idea?

Thank you in advance
Go to Top of Page

mvelettronica

Italy
5 Posts

Posted - 25 May 2017 :  14:27:13  Show Profile  Reply with Quote
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.....
Best regards
Go to Top of Page

quinncurtis

1586 Posts

Posted - 25 May 2017 :  18:45:19  Show Profile  Reply with Quote
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.

For example:

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.
Go to Top of Page

mvelettronica

Italy
5 Posts

Posted - 26 May 2017 :  14:19:13  Show Profile  Reply with Quote
Hello,
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?
Best regards
Go to Top of Page

quinncurtis

1586 Posts

Posted - 26 May 2017 :  18:27:37  Show Profile  Reply with Quote
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.
Go to Top of Page

mvelettronica

Italy
5 Posts

Posted - 27 May 2017 :  10:51:40  Show Profile  Reply with Quote
Hello,
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.
Thank you
Have a good day
Go to Top of Page

quinncurtis

1586 Posts

Posted - 27 May 2017 :  18:08:53  Show Profile  Reply with Quote
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.
Go to Top of Page

mvelettronica

Italy
5 Posts

Posted - 28 May 2017 :  14:56:30  Show Profile  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07