I found a sollution. Like always i did not understand how the videoinput object really works. Instead of one flushdata i repeat the flushing till only 100 frames are stored in the buffer... so keeping the memory constant...
while vid.FramesAvailable>100
flushdata(vid,'trigger');
end
I still think there must be a more elegant sollution ....