Documentation ¶
Index ¶
- Variables
- type Allocator
- func (a *Allocator) Account(size int) error
- func (a *Allocator) Allocate(size int) []byte
- func (a *Allocator) Allocated() int64
- func (a *Allocator) Free(b []byte)
- func (a *Allocator) MaxAllocated() int64
- func (a *Allocator) Reallocate(size int, b []byte) []byte
- func (a *Allocator) TotalAllocated() int64
- type LimitExceededError
- type Manager
Constants ¶
This section is empty.
Variables ¶
var DefaultAllocator = memory.DefaultAllocator
DefaultAllocator is the default memory allocator for Flux.
This implements the memory.Allocator interface from arrow.
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator struct { // Limit is the limit on the amount of memory that this allocator // can assign. If this is null, there is no limit. Limit *int64 // Manager holds the Manager for this Allocator. // If this Allocator has a limit set and the limit is to be exceeded, // it will attempt to use the Manager to request more memory. // If this fails, then the Allocator will panic. Manager Manager // Allocator is the underlying memory allocator used to // allocate and free memory. // If this is unset, the DefaultAllocator is used. Allocator memory.Allocator // contains filtered or unexported fields }
Allocator tracks the amount of memory being consumed by a query.
func (*Allocator) Account ¶ added in v0.48.0
Account will manually account for the amount of memory being used. This is typically used for memory that is allocated outside of the Allocator that must be recorded in some way.
func (*Allocator) Allocate ¶
Allocate will ensure that the requested memory is available and record that it is in use.
func (*Allocator) Free ¶
Free will reduce the amount of memory used by this Allocator. In general, memory should be freed using the Reference returned by Allocate. Not all code is capable of using this though so this method provides a low-level way of releasing the memory without using a Reference. Free will release the memory associated with the byte slice.
func (*Allocator) MaxAllocated ¶
MaxAllocated reports the maximum amount of allocated memory at any point in the query.
func (*Allocator) Reallocate ¶ added in v0.48.0
func (*Allocator) TotalAllocated ¶ added in v0.49.0
TotalAllocated reports the total amount of memory allocated. It counts all memory that was allocated at any time even if it was released.
type LimitExceededError ¶
LimitExceededError is an error when the allocation limit is exceeded.
func (LimitExceededError) Error ¶
func (a LimitExceededError) Error() string
type Manager ¶ added in v0.50.0
type Manager interface { // RequestMemory will request that the given amount of memory // be reserved for the caller. The manager will return the number // of bytes that were successfully reserved. The n value will be // either equal to or greater than the requested number of bytes. // If the manager cannot reserve at least bytes in memory, then // it will return an error with the details. RequestMemory(want int64) (got int64, err error) // FreeMemory will inform the memory manager that this memory // is not being used anymore. // It is not required for this to be called similar to how // it is not necessary for a program to free the memory. // It is the responsibility of the manager itself to identify // when this allocator is not used anymore and to reclaim any // unfreed memory when the resource is dead. FreeMemory(bytes int64) }
Manager will manage the memory allowed for the Allocator. The Allocator may use the Manager to request additional memory or to give back memory that is currently in use by the Allocator when/if it is no longer needed.