Documentation
¶
Overview ¶
Package offheap holds large buffers (rasters, clipboard payloads) in memory-go memory instead of on the Go heap, so their pages go back to the system the moment their owner frees them rather than lingering as garbage that raises the heap goal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBufferDone = errors.New("offheap: buffer already taken or freed")
ErrBufferDone reports a write to, or a Take of, a Buffer already taken or freed.
var ErrBufferFull = errors.New("offheap: buffer full")
ErrBufferFull reports a write past the most a Buffer holds.
Functions ¶
func Clone ¶
Clone copies src into memory mem holds, and returns the slice to free it by. src is not empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is an io.Writer whose bytes mem holds, for a payload of unknown size: it grows by doubling, from bufferChunk, never past its most. It holds the only handle to its memory, so no stale handle outlives a resize. One goroutine may write while another takes or frees it: a write after that fails with ErrBufferDone instead of touching freed memory.
func (*Buffer) Free ¶
Free frees whatever the Buffer holds and refuses writes afterwards. Freeing it again, or after Take, does nothing.