offerPooledBacking static method

void offerPooledBacking(
  1. Uint8List buffer
)

Offers a fixed-capacity empty buffer back to the matching free-list.

Only exact 64 KiB / 1 MiB buffers are recycled so other grown allocations cannot pin large heaps in the pool.

Implementation

static void offerPooledBacking(Uint8List buffer) {
  if (buffer.length == _defaultInitialCapacity) {
    if (_defaultPool.length >= _maxPooledDefaultBackings) return;
    if (_defaultPool.contains(buffer)) return;
    _defaultPool.add(buffer);
    return;
  }
  if (buffer.length == _largeCapacity) {
    if (_largePool.length >= _maxPooledLargeBackings) return;
    if (_largePool.contains(buffer)) return;
    _largePool.add(buffer);
  }
}