Class WriteBufferManager
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
A memory budget for memtables, shared across column families and across
databases. Maps to rocksdb_write_buffer_manager_t.
public sealed class WriteBufferManager : RocksDbHandle, IDisposable
- Inheritance
-
WriteBufferManager
- Implements
- Inherited Members
Remarks
WriteBufferSize bounds one memtable. It says nothing about the total, so a process with many column families or several databases has no way to cap how much memory their memtables take together. This does.
Attach it with WriteBufferManager. RocksDb takes a shared reference, so this object may be disposed once assigned, and sharing one instance between databases is the point: they then draw on a common budget rather than each having their own.
Properties
AllowStall
Whether writers are stalled when the budget is exhausted.
public bool AllowStall { set; }
Property Value
Remarks
Write-only: RocksDb exposes no getter for it.
BufferSize
The budget, in bytes. Zero disables enforcement.
public ulong BufferSize { get; set; }
Property Value
CostsToCache
Whether this manager charges its memory against a cache.
public bool CostsToCache { get; }
Property Value
DummyEntriesInCacheUsage
Memory the manager has reserved in its cache through placeholder entries, in bytes.
public ulong DummyEntriesInCacheUsage { get; }
Property Value
Remarks
Zero unless the manager was created with a cache. This is how memtable memory is made visible to the cache's accounting.
IsEnabled
Whether the manager is enforcing a budget, which it is only when the buffer size is non-zero.
public bool IsEnabled { get; }
Property Value
MemoryUsage
Memory currently attributed to memtables, in bytes, including those already sealed and waiting to be flushed.
public ulong MemoryUsage { get; }
Property Value
MutableMemtableMemoryUsage
Memory attributed to memtables still accepting writes, in bytes.
public ulong MutableMemtableMemoryUsage { get; }
Property Value
Remarks
The difference between this and MemoryUsage is memory held by memtables that are sealed and waiting on a flush. A large gap means flushing is not keeping up.
Methods
Create(ulong, Cache, bool)
Creates a manager that charges its memory against
cache, so that memtables and cached blocks compete for
one budget.
public static WriteBufferManager Create(ulong bufferSize, Cache cache, bool allowStall = false)
Parameters
Returns
Remarks
Useful when the real constraint is total process memory rather than memtable memory specifically. The manager inserts placeholder entries into the cache to account for what the memtables hold; see DummyEntriesInCacheUsage.
Create(ulong, bool)
Creates a manager with a budget of bufferSize bytes.
public static WriteBufferManager Create(ulong bufferSize, bool allowStall = false)
Parameters
bufferSizeulongThe total memtable budget. Zero disables the manager, which then tracks usage without enforcing anything.
allowStallboolWhether writers are stalled when the budget is exhausted. When false, the budget is enforced by flushing sooner rather than by blocking.
Returns
DisposeHandle()
Releases the native handle. Called during disposal.
protected override void DisposeHandle()
Remarks
Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().