LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ClearListCtrl Does not free memory resources

I use a listbox to display text messages in different colors. I use a callback function that an operator uses to clear the list box by calling ClearListCtrl(panelHandle,PANEL_LISTBOX). This does clear the items in the listbox. However, the memory allocated for the list items does not get deallocated as seen by Windows Task Manager. Also, I have noticed a slow down in my application when I have inserted more than 10000 items into the listbox.
 
Any ideas?
0 Kudos
Message 1 of 5
(3,493 Views)
Hello hornsbyr,
 
Just for some background information: which version of CVI are you using, also how are you storing the information before you use InsertListItem?  Are you dynamically allocating memory for your information then storing it in the list?  If so, you might not be deallocating that memory.  Also, if you use the following command instead:
DeleteListItem (treePanel, TREEPANEL_TREE, 0, -1do you see the same behavior? 
 
Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 5
(3,470 Views)
LabWindows/CVI has its own internal memory manager which is used to manage memory allocation requests that come from inside CVI (such as from UI controls). This memory manager obtains memory from the system in chunks, as needed, but doesn't always return memory to the system as soon as it becomes available (it has some fairly complicated logic for when it should return memory to the system, mainly for performance reasons).
 
So what you are seeing is that even though the list control has freed up its memory when you remove all those items, and the memory is now free as far as the CVI memory manager is concerned, you cannot see this "freed memory" using the Windows Task Manager. However, if you were to request another large allocation after freeing these items, you should notice that CVI will not need to allocate additional memory from the system.
 
Basically, a good rule of thumb, when you suspect a memory leak somewhere, is to put the action that you are suspicious of in a loop. Do it 100 or 200 times, and see if you are gradually losing memory from the system. If you are, then there is a memory leak. If not, then there is probably no leak. It's just that a lot of allocations take place on an "as needed" basis, so things don't always return to their pristine state after a single create/discard iteration.
 
Luis
NI
0 Kudos
Message 3 of 5
(3,460 Views)

Mr Luis,

I have a similar problem. I am using LW ver 5.5 and acquiring data through GPIB, then ploting it on a graph. The graph points are increasing and at about 5000 points the system becomes dead slow. I think in the system,  free memory is getting exhausted. Here there is no memory leak. still why it is so?. I want the graph control in the retain mode as I need to rescale the plot.  Could you look into this problem?

Regards

Sajy

0 Kudos
Message 4 of 5
(3,434 Views)
What kind of plots are you using? Are you plotting one point-per-plot (PlotPoint function)? Or are you plotting multiple array-type plots, of increasing size?
 
Can you write a small sample program that reproduces this behavior and attach it here?
 
Luis
0 Kudos
Message 5 of 5
(3,408 Views)