// Byte slice pool with 1k slice capacity, 100 pool capacity
pool := rebytes.NewPool(1024, 100)
byteSlice := pool.Get()
pool.Put(byteSlice)
// Like bytes.Buffer, but with dynamic memory managed by the pool
buf, err := rebytes.NewBuffer(pool)
buf.WriteString("Hello World")
This software is considered ALPHA quality. Not recommended for production use.
Package rebytes provides types that recycle bytes slices to reduce allocation and garbage collection:
rebytes.Pool
: a[]byte
pool that provides/recycles fixed capacity slices from a fixed-maximum-size pool.rebytes.Buffer
: abytes.Buffer
analogue that dynamically gets/returns memory from arebytes.Pool
.
Copyright 2017 by David A. Golden. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0