Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteMPool(mp *MPool)
- func GlobalCap() int64
- func InitCap(cap int64)
- func MPoolControl(tag string, cmd string) string
- func MakeSlice[T any](n int, mp *MPool) ([]T, error)
- func MakeSliceArgs[T any](mp *MPool, args ...T) ([]T, error)
- func MakeSliceWithCap[T any](n, cap int, mp *MPool) ([]T, error)
- func ReportMemUsage(tag string) string
- type MPool
- func (mp *MPool) Alloc(sz int) ([]byte, error)
- func (mp *MPool) Cap() int64
- func (mp *MPool) CurrNB() int64
- func (mp *MPool) DisableDetailRecording()
- func (mp *MPool) EnableDetailRecording()
- func (mp *MPool) Free(bs []byte)
- func (mp *MPool) GetSels() []int64
- func (mp *MPool) Grow(old []byte, sz int) ([]byte, error)
- func (mp *MPool) Grow2(old []byte, old2 []byte, sz int) ([]byte, error)
- func (mp *MPool) PutSels(sels []int64)
- func (mp *MPool) Report() string
- func (mp *MPool) ReportJson() string
- func (mp *MPool) Stats() *MPoolStats
- type MPoolStats
Constants ¶
View Source
const ( NumFixedPool = 5 B = 1 KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB PB = 1024 * TB )
View Source
const ( NoFixed = 1 NoLock = 2 )
View Source
const ( Available = iota )
Variables ¶
View Source
var PoolElemSize = [NumFixedPool]int32{64, 128, 256, 512, 1024}
Pool emement size
Functions ¶
func DeleteMPool ¶
func DeleteMPool(mp *MPool)
func MPoolControl ¶
func MakeSliceArgs ¶
Types ¶
type MPool ¶
type MPool struct {
// contains filtered or unexported fields
}
The memory pool.
func MustNewNoFixed ¶ added in v0.8.0
func MustNewZero ¶
func MustNewZero() *MPool
func MustNewZeroNoFixed ¶ added in v0.8.0
func MustNewZeroNoFixed() *MPool
func (*MPool) DisableDetailRecording ¶
func (mp *MPool) DisableDetailRecording()
func (*MPool) EnableDetailRecording ¶
func (mp *MPool) EnableDetailRecording()
func (*MPool) Grow ¶
Grow is like reAlloc, but we try to be a little bit more aggressive on growing the slice.
func (*MPool) ReportJson ¶
func (*MPool) Stats ¶
func (mp *MPool) Stats() *MPoolStats
type MPoolStats ¶
type MPoolStats struct { NumAlloc atomic.Int64 // number of allocations NumFree atomic.Int64 // number of frees NumAllocBytes atomic.Int64 // number of bytes allocated NumFreeBytes atomic.Int64 // number of bytes freed NumCurrBytes atomic.Int64 // current number of bytes HighWaterMark atomic.Int64 // high water mark }
Stats
func GlobalStats ¶
func GlobalStats() *MPoolStats
func (*MPoolStats) RecordAlloc ¶
func (s *MPoolStats) RecordAlloc(tag string, sz int64) int64
Update alloc stats, return curr bytes
func (*MPoolStats) RecordFree ¶
func (s *MPoolStats) RecordFree(tag string, sz int64) int64
Update free stats, return curr bytes.
func (*MPoolStats) RecordManyFrees ¶
func (s *MPoolStats) RecordManyFrees(tag string, nfree, sz int64) int64
func (*MPoolStats) Report ¶
func (s *MPoolStats) Report(tab string) string
func (*MPoolStats) ReportJson ¶
func (s *MPoolStats) ReportJson() string
Click to show internal directories.
Click to hide internal directories.