LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Cvi out of memory, If keep calling the same function GetTableCellVal

I've got the message out of memory when I keep call the same function GetTablecellVal
in my program
0 Kudos
Message 1 of 7
(4,078 Views)
Hello huu,

I tried to recreate the issue you are seeing, but I was unable to do so. Which version of CVI are you using? In which cases are you getting the error? How many times are you calling the function? What error and error number are you receiving? Do you have a small example program demonstrating the error?


Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 7
(4,056 Views)
Please see my attachment, Thanks for your response.
0 Kudos
Message 3 of 7
(4,045 Views)
When you call GetTableCellVal on a picture cell, you then need to free the bitmap. The bitmap that is passed to you is a copiy, not a reference.

Here is the relevant passage from the GetTableCellVal function help:

"If the cell type is VAL_CELL_PICTURE, the function returns the bitmap stored in the cell, or zero if there is no bitmap. When you no longer need the bitmap, free it using DiscardBitmap."

Luis
NI
0 Kudos
Message 4 of 7
(4,027 Views)
Hi LuisG

That's work!.
Thanks alot
0 Kudos
Message 5 of 7
(4,019 Views)
Hi ,

The information you provided correct the problem.
I have one more question:
If the cell type is VAL_CELL_STRING. When I no longer need it, Do I have to free it ?

Huu
0 Kudos
Message 6 of 7
(4,007 Views)
If the cell type is VAL_CELL_STRING and you are calling GetTableCellVal, then you need to allocate the memory and then free it when you no longer need it. Like this:

--------------
GetTableCellValLength (panel, control, cell, &strLength);
strBuffer = (char *)malloc (strLength + 1); // +1 in order to accomodate the 0 at the end
GetTableCellVal (panel, control, cell, strBuffer);

.... // this is the code that uses the string

free (strBuffer);
--------------

However, if instead of GetTableCellVal you are calling GetTableCellRangeVals in order to get the data for multiple cells at a time, then you don't need to allocate the individual string buffers. CVI will do it for you. But you then need to free them using the FreeTableValueStrings function.

Luis
NI
0 Kudos
Message 7 of 7
(3,997 Views)