Showing results for 
Search instead for 
Did you mean: 

Graph > Retain Data - Stuck In Memory

Go to solution

I'm running LabWindows 2017 on Windows 10. My plot data is getting hung in memory upon program exit.

I'm dynamically allocating an array for plotting data on a graph using the PlotWaveform ( ) function. The array dynamic memory is freed right after use, inside the plot function. The graph is set to the Retain Data mode. I need to specifically use the PlotWaveform () function and Retain Data for this particular application so other plotting functions like PlotY () are not an option..


When I exit the program, Resource Tracking shows plot data still resident in memory. When the Data Mode is set to Discard, the data is no longer present in memory, so the problem lies with CVI making a copy of the data when Retain Data is active. I'm trying to find the correct way to clear that CVI internal data copy from memory just before the program exit (0) function is called.


What doesn't work:
DeleteGraphPlot () using actual plot handles to delete the plot.

DeleteGraphPlot () using the -1 argument to delete all graphs.

DiscardGraph ();

DiscardPanel ();

QuitUserInterface ();

Anyone know the secret handshake for clearing the plot data from memory?

Message 1 of 4
Accepted by topic author scottrod

That is just weird because DiscardPanel cleans up all data allocated by the UIR, including data retained by plots. I've just tested this extensively with the resource tracker recently on CVI2020 on a memory hungry program that does use a lot of PlotWaveform.

0 Kudos
Message 2 of 4

Thanks for the reply, it made me look deeper into my code and found a fork that would sometimes allow it to wipe the memory, sometimes not. It's a convoluted problem, but mea culpa. Thanks!

0 Kudos
Message 3 of 4

As a follow-up, the program required the use of DiscardCtrl (panel, Panel_Graph) to properly clear the plot data from memory when the Retain Data mode graph parameter was selected. DiscardPanel (panel) alone would not clear it.

DiscardCtrl (panel, Panel_Graph) was not required when the graph mode was set to Discard Data mode.

0 Kudos
Message 4 of 4