Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory problem with Waveform Graph control

Hi all!

I use the NI waveform graph control (7.1) to plot simple but large arrays of doubles (e.g. 1.000.000 data points with .PlotY(array):

            double[] MyArrayD = new double[1000000];
            <fill array with data>     
            oMyGraph.PlotY( MyArrayD );

The  waveform graph control allocates a lot of memory and even though I destroy the array and clear the graph (oMyGraph.Clear()), the memory won't be released. Also the oMyGraph.Dispose() method doesn't free memory.

Is this a bug or deos anybody know a  workaround?

Best  regards,
Andreas
   
0 Kudos
Message 1 of 5
(3,766 Views)

Hi Andreas

It is possible to attach a little example where the problem occurs?

What Version of Measurement Studio do you use?

regards

Manuel

0 Kudos
Message 2 of 5
(3,729 Views)
Hi Manuel,
 
the WaveformGraph control I'm using in Visual Studio.NET 2003 shows me version 7.1.0.306.
 
I have attached a very simple C# project with an array of 1000000 elements. If you press the "Create Array" button the memory consumption goes from about 17 to 25 MBytes. Then press the "Plot data" button and the memory goes to 76 MBytes. Neither the "Clear Data" nor the "Dispose" button will then release the memory.
 
Best regards,
Andreas
 
 
0 Kudos
Message 3 of 5
(3,727 Views)

Hello Andreas

ClearData() removes all of the graph history data from all the graph plots. Calling Dispose on the graph does cleanup on unmanaged resources that the graph uses, plus cleans up any user objects and gdi handles being used (you can use the task manager to check these handles). The array that you created is a managed resource and will be handled by the garbage collector (GC) . The GC is optimized enough to handle managed data and usually fires automatically if it feels the memory pressure building up. The GC is not deterministic so setting the array to null does not guarantee that the array will be freed when the method goes out of scope. It is not considered good practice to force the GC to collect, but you can if you need to. It's better for performance if you leave it up to the GC when to start collections.

If you want to force cleanup, call
            GC.Collect();
            GC.WaitForPendingFinalizers(); 

You don't need to call dispose.

Check out these links for more information

Chapter 5 — Improving Managed Code Performance
To set to Nothing (null) or not...


I hope this helps
Bilal Durrani
NI
0 Kudos
Message 4 of 5
(3,712 Views)
Hi Bilal and Manuel,
 
the problem appeared to me due to the GC doesn't release memory as long as enough memory is left in system, even though I wait a long time.
If system memory consumption then increases (I started some additional apps) the GC do its job and releases the memory.
 
I know that the Dispose method is not required, it was more an act of deperation 😉
 
Sorry for the inconvenience and thanks for your help!
 
Best regards,
Andreas
0 Kudos
Message 5 of 5
(3,697 Views)