cockroach: github.com/abhinavdahiya/cockroach/util/bufalloc Index | Files

package bufalloc

import "github.com/abhinavdahiya/cockroach/util/bufalloc"

Index

Package Files

byte_allocator.go

type ByteAllocator Uses

type ByteAllocator []byte

ByteAllocator provides chunk allocation of []byte, amortizing the overhead of each allocation. Because the underlying storage for the slices is shared, they should share a similar lifetime in order to avoid pinning large amounts of memory unnecessarily. The allocator itself is a []byte where cap() indicates the total amount of memory and len() is the amount already allocated. The size of the buffer to allocate from is grown exponentially when it runs out of room up to a maximum size (chunkAllocMaxSize).

func (ByteAllocator) Alloc Uses

func (a ByteAllocator) Alloc(n int, extraCap int) (ByteAllocator, []byte)

Alloc allocates a new chunk of memory with the specified length. extraCap indicates additional zero bytes that will be present in the returned []byte, but not part of the length.

func (ByteAllocator) Copy Uses

func (a ByteAllocator) Copy(src []byte, extraCap int) (ByteAllocator, []byte)

Copy allocates a new chunk of memory, initializing it from src. extraCap indicates additional zero bytes that will be present in the returned []byte, but not part of the length.

Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).