# Run-time of function RingBuffer::ChangeCount(int numBuffers, DeviceUpdateMode mode)

**URL:** <https://forum.commonvisionblox.com/t/run-time-of-function-ringbuffer-changecount-int-numbuffers-deviceupdatemode-mode/653>\
**Category:** C++ API\
**Tags:** ringbuffer\
**Created:** [January 15, 2019, 2:32pm UTC](https://forum.commonvisionblox.com/t/run-time-of-function-ringbuffer-changecount-int-numbuffers-deviceupdatemode-mode/653 "2019-01-15T14:32:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tm5](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tm5](https://forum.commonvisionblox.com/u/tm5)\
**Post date:** [January 15, 2019, 2:32pm UTC](https://forum.commonvisionblox.com/t/run-time-of-function-ringbuffer-changecount-int-numbuffers-deviceupdatemode-mode/653/1 "2019-01-15T14:32:08Z")

</div>

Dear all,

the run-time of the function (int numBuffers, DeviceUpdateMode mode) with numBuffers = 10000 takes about 30 seconds. With higher numbers it the run-time increases in a linear way.

Any ideas how I can improve this or how the function can be called in a better way?  
Has the run-time something todo with the camera or the equipment which is connected?

Regards

---

<div class="post-metadata">

**Author:** ![CvK](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/cvk/32/112_2.png) [@CvK](https://forum.commonvisionblox.com/u/CvK)\
**Post date:** [January 15, 2019, 7:18pm UTC](https://forum.commonvisionblox.com/t/run-time-of-function-ringbuffer-changecount-int-numbuffers-deviceupdatemode-mode/653/2 "2019-01-15T19:18:05Z")

</div>

Well, that is quite a high number of buffers. Allocating that ammount of memory could take quite a while (depending on the size of the image you are setting the buffer for).

I’m assuming you need this high buffer count for a high speed video recording of some sort?

---

<div class="post-metadata">

**Author:** ![Andreas](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/andreas/32/75_2.png) [@Andreas](https://forum.commonvisionblox.com/u/Andreas)\
**Post date:** [January 15, 2019, 8:25pm UTC](https://forum.commonvisionblox.com/t/run-time-of-function-ringbuffer-changecount-int-numbuffers-deviceupdatemode-mode/653/3 "2019-01-15T20:25:17Z")

</div>

Ok, 30s is a bit much. However there are some scenarios where allocating can take a long time. Consider the following:

- you are close to your systems maximum RAM - therefore you might see swapping effects
- e.g switching from 9999 to 10000 will allocate 10000 buffers before freeing 9999 as a result you might come closer to your limit than expected.

When switching between high buffer numbers consider an additional step to reduce them first. So switch from 9999 to 3 (could be 1 but for some drivers 3 is the minimum) to 10000.
