LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetTableCellRangeVals leads to "out of memory" error

Hello all,

I use CVI 6.0. There is a table control in my application that has up
to 48 columns and 32 rows.
(Always dynamically inserted after deleting all previous rows and
columns.)
No problem with 24 columns and 16 rows or less. But in case of maximum
size I may call the function that calls GetTableCellRangeVals ()
successfully twice, while the third call of the function containing
this call evokes a "Library function error: Out of memory.". Windows'
Taskmanager displays 388 MB free memory.
I called CVIDynamicMemoryInfo() before and after each call of this
function - always showing the same values. So I assume there is no
progressive memory consumption due to malloc()
For test purposes I repeated the call of GetTableCellRangeVals() 5
times consecutively - same error message after the 5th call.

Any ideas what the reason or ways to find it could be?

Thank you in advance

André Lehmann

0 Kudos
Message 1 of 3
(2,964 Views)
Addition:
Cell type is VAL_CELL_PICTURE. I allocate an array of
columns*rows*sizeof(int) and pass its address as 4th parameter to
GetTableCellRangeVals()
(int GetTableCellRangeVals (int panelHandle, int controlID, Rect
cellRange, void *valueArray, int direction);)

I want to get information which cells have been assigned a bitmap and
which have not.

part of my source code:
----------------------------------
int *pSelCells = NULL, i_rows, i_cols;
....
GetNumTableRows(hPanCnvPlSel, CNV_SELECT_TABLE_PLATE, &i_rows);
GetNumTableColumns(hPanCnvPlSel, CNV_SELECT_TABLE_PLATE, &i_cols);
pSelCells = malloc(i_rows * i_cols * sizeof(int));
r_Rect = MakeRect(1,1,i_rows,i_cols);
i = GetTableCellRangeVals (hPanCnvPlSel, CNV_SELECT_TABLE_PLATE,
r_Rect, pSelCells, VAL_COLUMN_MAJOR);
....
free(pSelCells)
----------------------------------

The 4th or 5th call of a function containing this excerpt leads to the
said error.

0 Kudos
Message 2 of 3
(2,960 Views)

Hi,

 From help CVI 7.1 for GetTableCellRangeVals

 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 bitmaps, free them using DiscardBitmap. When allocating the array, assume that each element requires four bytes of storage.
try this->

for (x=0;x<i_rows*i_cols;x++)DiscardBitmap(pSelCells[x]);

before

free(pSelCells[x]);

0 Kudos
Message 3 of 3
(2,934 Views)