Ring Buffer

What Does Ring Buffer Mean?

A ring buffer is a data structure that is treated as circular although it its implementation is linear. A circular buffer is typically used as a data queue. A circular buffer is a popular way to implement a data stream because the code can be compact.


A ring buffer is also known as a circular buffer, circular queue or cyclic buffer.

Techopedia Explains Ring Buffer

A ring buffer is a common implementation of a queue. It is popular because circular queues are easy to implement. While a ring buffer is represented as a circle, in the underlying code, a ring buffer is linear. A ring buffer exists as a fixed-length array with two pointers: one that represents the head of a queue, and another that represents the tail. In a queue, elements are added to the tail of the queue in a “FIFO” (first in-first out) fashion. The first elements of the queue are removed from the head in the order they were added. When the head pointer gets to the end of the array, it wraps around to the first element in the array. Any data in the buffer is overwritten. The head of the queue is different from the first element in the actual array and both pointers move as elements are added and removed.

One disadvantage of a ring buffer is its fixed size. For queues where elements need to be added and removed in the middle, not just at the start and end of a buffer, an implementation as a linked list is the preferred approach.


Related Terms

Latest Software Development Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…