LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory leak in dll with an imaq-function

Solved!
Go to solution

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

0 Kudos
Message 1 of 5
(2,423 Views)

Hi,

 

Haven't seen any leaks in IMAQtoArray. The code below working without any leaks:

 

Snippet.png

 

Show your code please. It seems to be something else wrong.

 

Andrey.

0 Kudos
Message 2 of 5
(2,420 Views)

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

0 Kudos
Message 3 of 5
(2,414 Views)

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??? 😞

0 Kudos
Message 4 of 5
(2,410 Views)
Solution
Accepted by topic author kper

Sorry everyone for bothering you.

I was just stupid.... the answer is of course imaqDispose(void *object)

 

Sorry again

Thanks for the help

0 Kudos
Message 5 of 5
(2,409 Views)