Documentation ¶
Overview ¶
Package allocator implements byte slice pooling management to reduce the pressure of memory allocation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClassAllocator ¶
type ClassAllocator struct {
// contains filtered or unexported fields
}
ClassAllocator is a bytes pool. The size of bytes satisfies 1 << n.
func NewClassAllocator ¶
func NewClassAllocator() *ClassAllocator
NewClassAllocator creates a new ClassAllocator.
func (*ClassAllocator) Free ¶
func (a *ClassAllocator) Free(bts interface{})
Free releases the bytes to pool.
func (*ClassAllocator) Malloc ¶
func (a *ClassAllocator) Malloc(size int) ([]byte, interface{})
Malloc gets a []byte from pool. The second return param is used to Free. We may also use first return param to Free bytes, but this causes an additional heap allocation. See https://github.com/golang/go/issues/8618 for more details.
Click to show internal directories.
Click to hide internal directories.