LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Textbox + memory allocation

Hi,

With LabWindows CVI 7.1.1 on Xp

If I insert many, many lines in a textbox, CVI uses a lot of memory (ExtraLines = -1) sometimes untill 1, 5Go.
(My soft run all night long, and the following morning my PC shouts "not enough memory" or something like that)

So, in order to "release" the memory, I use "ResetTextbox" with no_text or DeleteTextBoxLines (All).
The TextBox is cleared but the memory used doesn't.

It seems that the memory allocated is just cleared to be used by other INSERT, but not freed.
Since it has been allocated, it left allocated.

Am I wrong ?

Is there any way to free the memory allocated by a TextBox ?

Perhaps, an awful "DiscardCtrl" + "NewCtrl" will work, but I will use this in last resort.

Thanks for help.
Npr.




0 Kudos
Message 1 of 7
(4,198 Views)
It seems unlikely that anyone actually reads your 1.5Gb of text  Smiley Wink : as you seem easy with the idea of readily deleting the contents it would seem to make more sense to limit the text box to just a few thousand lines. If you really need all the data, write it to a log file...
 
JR
0 Kudos
Message 2 of 7
(4,184 Views)
Thanks for your answer.

Of course, you're right.
I use the textbox as a "LogBox".
So I let it live and then pick up some informations when a problem occures.
And I also keep only 15 days in it (the 1.5 Gb is on an old version).
I can't set a maximum number of lines because it depends on events.

So my actual question is :
How to free the memory allocated by a textbox ?

Is it not a kind of bug that a ResetTextBox does not de-allocate the memory ?

Npr
0 Kudos
Message 3 of 7
(4,174 Views)
Nico,
 
In general, the CVI run-time engine holds on to the memory that you have already allocated, even if you subsequently free it, rather than returning it to Windows. The reason for this is that in most situations, user programs tend to want to reallocate the memory sooner or later. By keeping it around (on "stand-by", if you will) it greatly improves performance over the alternative release/free/release/free/...
 
In CVI 7.1, the only situation when unused memory was returned to the system was when a panel (any panel) was discarded. As of CVI 8.1, memory is also returned to the system when discarding a control (any control) or when deleting a large number of ring, list, or tree items, or table cells. Not when clearing a textbox, unfortunately.
 
Luis
0 Kudos
Message 4 of 7
(4,162 Views)
Thank you, Luis, for your constructive answer.

Now I know without ambiguity I have to find another way to do my stuff.

NicoP
0 Kudos
Message 5 of 7
(4,150 Views)
Well, you could for example use a history logfile and display only the last lines in the textbox, always appending text to the end with SetCtrlVal and deleting lines from the top, limiting the size of the textbox.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(4,137 Views)

Nico,

If you'd like to follow Roberto's suggestion (which I also recommend), you should know that textboxes have an attribute (ATTR_EXTRA_LINES) that automatically control how many non-visible lines of text your control can hold. By using that attribute, you won't have to ever explicitly delete lines.

Luis

0 Kudos
Message 7 of 7
(4,103 Views)