08-16-2011 11:14 AM
Hi,
I am currently writing a dll which uses the imaqImageToArray function.
Of course this function allocates new memory every time it converts a picture, and as I convert 180 pics a second and the Program shopuld run for hours that is quite a problem for me.
The solution should of course be the function free(void* MyPointer). And if I use malloc to allocate some random memory, instead of the imaqImageToArray, this works perfectly.
However when I call free() to release memory allocated by the imaqImageToArray function, the dll/LabView-Program will crash.
So I wonder what function the imaq-Functions use to allocate memory and how I can get rid of it again. Is there another imaq-function?
Thanks already!
Greetings
Solved! Go to Solution.
08-16-2011 11:31 AM
Hi,
Haven't seen any leaks in IMAQtoArray. The code below working without any leaks:
Show your code please. It seems to be something else wrong.
Andrey.
08-16-2011 12:21 PM
Hi,
sorry for the misunderstanding. I use the imaqImageToArray function inside the .dll. The Code Hence is a c-code.
#include "extcode.h"
#include "nivision.h"
... some stuff/the dll-function etc....
uint8_t *Pointer;
Pointer = (uint8_t)imaqImageToArray(MyImage,MyRect,&Rows,&Columns);
if(Pointer!= NULL)
{
free(Pointer);
}
... other stuff
Sadly I can't find a detailed description of the function. I assume the void* Pointer returned by imaqImageToArray points to an Array, however I am not sure wether it points to a usual c-array or a LabView Array, meaning:
typedef struct {
int32_t dimSize;
double Element[1];
} LVArray;
That would explain why free(); won't work.
I think I got a step further though, as I found a function in the "extcode.h" called DSDisposePtr(void *p). That should be the equivalent to free() for LabView Datastructures.
However even though I have included everything from the cintools directory explicitly to the project, the Linker complains about a not found externic object. Anyone knows which .lib files I need to include where to be able to use that function?
Thanks
08-16-2011 12:33 PM
Quick update: I managed to compile it, however DSDisposePtr() is not the solution, as the memory leek still exists. Probably only sets the Pointer to a NULL-Pointer??? 😞
08-16-2011 12:40 PM
Sorry everyone for bothering you.
I was just stupid.... the answer is of course imaqDispose(void *object)
Sorry again
Thanks for the help