Reference Count GenICam.vin CVB 13.01.xxx

Hi @Amicelli

an important rule about reference counting is this: Never expect the reference count to have a specific value! Of course the reference count is not generally arbitrary. After loading a driver (or an image or a video or an emu) I can reasonably expect the reference count to have a value > 0. If I call ShareObject on it, I can reasonably expect it to have a value higher than before. If I call ReleaseObject on it I can expect the value to smaller than before. But the actual value (or the offset by which it changes when calling ShareObject or ReleaseObject) is an implementation detail and is subject to change without further notice (which I think is reasonable as well - after all nobody every promised the reference count to have the value x in any given situation).

In summary I’d say that the assertion that after loading the driver has a reference count of exactly 2 was a problematic one (and the assertion that it is exactly 1 would be equally problematic).

For those who are now scratching their heads I have two good news:

  1. Since version 13.00.000 the IsImage function is finally back on track and you can rely on it to give a correct answer without running into undefined behavior. This alone might make a few of the ReferenceCount calls that people have been using obsolete.
  2. What’s even better is that with the new CVB.Net, CVB++ and CVBpy APIs you won’t have to worry about reference counting ever again because the smart pointers (CVB++) or the runtime (CVB.Net, CVBpy) will take care of that detail…
4 Likes