View Full Version : MemBufferCollections Deallocate/Allocate large buffers problem?

May 16, 2005, 16:41:22
I have a DFG/MC4 grabber. My application using 4 cameras runs fine. I would like to use very large buffers (ideally up to 1.5 GB) in a 2.5GB system.

On the first memory allocation call, I can allocate 1.5 GB and use it without problem.

The problem occurs when I deallocate the memory buffers and then reallocate a new set of buffers because I have less or more cameras to grab frames from. I do this to maximize the amount of frame collection time per camera setup.

The application will quit when trying to allocate the new memory buffers. By using the task manager I found that the memory is not entirely deallocated when I set the memBufferCollection pointers to NULL. The deallocation is about 1/2 of the previously allocated memory.

By using a smaller allocation (900 Mbytes total) the application works, but the behaviour remains the same (partial deallocation). The reason why it works now is that the new memBufferCollection seems to be generated BEFORE the remainder buffers (memory that was not totally deallocated) is finally deallocated. This causes the application to temporarily trying to exceed the system memory. This is easily observed with the task manager set at high update rate and placing some Sleep(5000) calls after deallocation and after memory allocation.

Is this behaviour normal, or is there a way to get around it?


Stefan Geissler
May 17, 2005, 13:00:46

probably you delete the reference to the MemBufferCollection, but you do not delete the reference used by the Grabber object. You should also call
Grabber::setActiveMemBufferCollection( 0 ) ;

May 17, 2005, 14:14:42
Thanks! that did it.

This is probably the wrong place for this, but ever since I switched to a faster computer (2.2Ghz processor from 1Ghz) the device drivers for the four video capture devices fails to start some of these randomly.

Disabling then restarting the offending device is always successful (with device manager), in effect forcing the driver to restart. The only way to get around this is to hibernate instead of a clean shutdown.