08-04-2011 03:58 PM
Hi,
I have some problems with the memory management of MeasurementStudio 2010 on WinXP, .NET 2.0 and VisualStudio 2005.
I’m running a C# application with several instances of NI waveform graphs. Typically each graph contains 2 or 3 plots over one x- and y-axes. From time to time the waveform graphs are updated with new signal data, where new graphs and plots objects are created. The windows forms stay open all the time but the plot objects are completely new. Until one week ago this application was built with Measurement Studio 7.1.1 and worked OK so far but consumed a certain amount of memory each time the graphs are updated. This leaded to an out of memory exception after a few hundreds of updates. We used a memory profiler tool to track down the memory problems and found the leaks come from the NI waveform graph. Fortunately I was able to improve the memory consumption by unsubscribing the NI events and implementing explicit dispose calls on the NI objects (axes, plots, etc.) before creating new objects. With this “solution” the memory consumption was nearly acceptable and the application was running for quite a long time.
Now I upgraded my Measurement Studio to version 2010 (9.0.0.22) because I expected an improvement of the memory problem. I rebuilt my application, whereas it is still based on Visual Studio 2005 and .NET framework 2.0. When I run it the memory consumption seemed to be reduced at the first look, but already after about a hundred refreshes I was surprised to get an out of memory exception again. This time it was not the memory usage which reached the limit, it was rather the number of over 10000 handles the application had allocated. So I rebuild my application again with Meas. Studio 7.1.1 and run the same test. This version consumed only about 1500 handles after the same number of data updates. Why does Measurement Studio 2010 consume so much handles compared to v7.1.1?
Best regards,
Andy
08-08-2011 07:35 AM
Hi,
I did some further testing and found situations where I got out of memory exceptions already before the maximum number of handles are reached. In the last run my app used about 400 MB memory. The system has 3 GB where totally 1.5 GB is in use. The stack trace of the exception shows a method CopyYData in NationalInstruments.UI.Internal.XYDataManager:
**** Outer Exception ****
ExceptionType:CGRAMainException
Module:eGRAMain
Error:21
Message:Message not found
Details:
StackTrace:
---- Inner Exception ----
ExceptionType:OutOfMemoryException
Message:Eine Ausnahme vom Typ "System.OutOfMemoryException" wurde ausgelöst.
Source:NationalInstruments.UI
StackTrace: bei NationalInstruments.UI.Internal.XYDataManager.CopyYData[TStart,TIncrement](Double[] yData, Int32 startIndex, Int32 length, TStart start, TIncrement increment, Boolean append)
bei NationalInstruments.UI.Internal.CartesianPlotElement.CopyYData(Double[] yData, Int32 startIndex, Int32 length, Double start, Double increment, Boolean append)
bei NationalInstruments.UI.Internal.WaveformPlotElement.PlotY(Double[] yData, Int32 startIndex, Int32 length, Double start, Double increment)
bei NationalInstruments.UI.Internal.WaveformPlotElement.PlotY(Double[] yData, Double start, Double increment)
bei NationalInstruments.UI.WaveformPlot.PlotY(Double[] yData, Double start, Double increment)
bei DIT.WRT.GRAMain.CGRAMain.PlotGraphData(CGRAStripe oGRAStripeCtrl, CGRAGraph oGRAGraphCtrl, Double& dFrom, Double& dTo)
bei DIT.WRT.GRAMain.CGRAMain.StripesPopulateDisplay()
bei DIT.WRT.GRAMain.CGRAMain.UpdateDisplay(Boolean bWRTUpdateFilesInConfiguration, Boolean bUpdateStripes)
TargetSite:Void CopyYData[TStart,TIncrement](Double[], Int32, Int32, TStart, TIncrement, Boolean)
Any ideas?
Best regards,
Andreas
08-11-2011 02:53 AM
Hi Andy,
could you post an example of code that causes this leak? Ideally the code would be as small as possible while still recreating the error. Using dummy data should be enough.
The best thing would be for us at NI to reproduce the error from your code so we can document and fix it.
Thanks.
Joseph Tagg