Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I release the memory allocated by ImageToArray? (ActiveX)

Using IDE: Borland C++ Builder 6 / BDS 2006
 
When I write the program with IMAQ ActiveX interface, I meet a problem in using ImageToArray function.
 
I can get the image data by this way:
 
 
Variant imgData;
Byte *pDataBuf;
int iBufSize;
 
...
 
imgData=CWIMAQ1->Images->Items(Variant(1))->ImageToArray();
memcpy(pDataBuf,imgData.ArrayLock(),iBufSize);
imgData.ArrayUnlock();
 
...
 
The problem is : after I called the codes many times, my program occupys almost all the memory.
 
So I wanna know: How can I release the memory allocated by ImageToArray ?
 
I know NI will not support BCB/BDS, but this is an ActiveX question, i thinkSmiley Tongue
sorry for my poor english!
0 Kudos
Message 1 of 5
(3,692 Views)
why no one help me?

帖子被YF_Jacky在09-26-2006 01:04 AM时编辑过了

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

Hey YF_Jacky,

Have you tried calling "delete imgData"?  Let me know if that works for you.

Regards,

Ryan F.

0 Kudos
Message 3 of 5
(3,618 Views)

thanks

 

unfortunately, "delete imgData" still can not solve the problem:mansad:

 

 

0 Kudos
Message 4 of 5
(3,520 Views)
Hey YF_Jacky,
 
I can't claim that I'm an expert with Active X and so I'm wondering what you're trying to accomplish with this line:
 
imgData=CWIMAQ1->Images->Items(Variant(1))->ImageToArray();
 
The examples I've seen using CWIMAQ1->Images have directly accessed the indexed image needed. Ex:
 
imgData=CWIMAQ1->Images(0)->ImageToArray();
 
(I have not tested this code so I'm not sure whether the pointer calls '->' or direct '.' function accessors are needed)
 
As far as I can tell the variable imgData should be released in memory as soon as it exits the scope of the program (I'm assuming that the imgData you've listed is a global variable).  Have you tried using a local variable for imgData?
 
Regards,
 
Ryan F.
0 Kudos
Message 5 of 5
(3,505 Views)