Documentation ¶
Index ¶
- Constants
- func NewFixedSizeMmapAllocator(size uint64) (ret *fixedSizeMmapAllocator)
- func NewFixedSizeSyncPoolAllocator(size uint64) (ret *fixedSizeSyncPoolAllocator)
- func SetDefaultConfig(delta Config)
- func WriteProfileData(w io.Writer) error
- type AllocateInfo
- type Allocator
- type AtomicInteger
- type CAllocator
- type CheckedAllocator
- type Class
- type ClassAllocator
- type ClosureDeallocator
- type ClosureDeallocatorPool
- type Config
- type CounterInteger
- type Deallocator
- type FixedSizeAllocator
- type Freezer
- type FuncDeallocator
- type FunctionKey
- type HeapSampleValues
- type Hints
- type LeaksTracker
- type LeaksTrackingAllocator
- type LocationKey
- type ManagedAllocator
- type MetricsAllocator
- type MmapInfo
- type ProfileAllocator
- type Profiler
- type RandomAllocator
- type ReadOnlyAllocator
- type SampleInfo
- type SampleKey
- type SampleValues
- type ShardedAllocator
- type ShardedCounter
- type SizeBoundedAllocator
- type StacktraceID
- type Trait
- type TraitHolder
Constants ¶
View Source
const ( MB = 1 << 20 GB = 1 << 30 )
Variables ¶
This section is empty.
Functions ¶
func NewFixedSizeMmapAllocator ¶ added in v1.2.1
func NewFixedSizeMmapAllocator( size uint64, ) (ret *fixedSizeMmapAllocator)
func NewFixedSizeSyncPoolAllocator ¶ added in v1.2.1
func NewFixedSizeSyncPoolAllocator(size uint64) (ret *fixedSizeSyncPoolAllocator)
func SetDefaultConfig ¶ added in v1.2.1
func SetDefaultConfig(delta Config)
func WriteProfileData ¶ added in v1.2.4
Types ¶
type AllocateInfo ¶ added in v1.2.1
type AllocateInfo struct { Deallocator Deallocator Size uint64 }
type Allocator ¶ added in v1.2.1
type Allocator interface {
Allocate(size uint64, hint Hints) ([]byte, Deallocator, error)
}
func GetDefault ¶ added in v1.2.1
type AtomicInteger ¶ added in v1.2.1
type AtomicInteger[T any] interface { Add(T) T Load() T }
type CAllocator ¶ added in v1.2.1
type CAllocator struct {
// contains filtered or unexported fields
}
func NewCAllocator ¶ added in v1.2.1
func NewCAllocator() *CAllocator
func (*CAllocator) Allocate ¶ added in v1.2.1
func (c *CAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type CheckedAllocator ¶ added in v1.2.1
type CheckedAllocator struct {
// contains filtered or unexported fields
}
func NewCheckedAllocator ¶ added in v1.2.1
func NewCheckedAllocator( upstream Allocator, ) *CheckedAllocator
func (*CheckedAllocator) Allocate ¶ added in v1.2.1
func (c *CheckedAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type Class ¶ added in v1.2.1
type Class[T FixedSizeAllocator] struct { // contains filtered or unexported fields }
type ClassAllocator ¶ added in v1.2.1
type ClassAllocator[T FixedSizeAllocator] struct { // contains filtered or unexported fields }
func NewClassAllocator ¶ added in v1.2.1
func NewClassAllocator[T FixedSizeAllocator]( newAllocator func(size uint64) T, ) *ClassAllocator[T]
func (*ClassAllocator[T]) Allocate ¶ added in v1.2.1
func (c *ClassAllocator[T]) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type ClosureDeallocator ¶ added in v1.2.3
type ClosureDeallocator[T any, P interface { *T TraitHolder }] struct { // contains filtered or unexported fields }
func (*ClosureDeallocator[T, P]) As ¶ added in v1.2.3
func (a *ClosureDeallocator[T, P]) As(target Trait) bool
func (*ClosureDeallocator[T, P]) Deallocate ¶ added in v1.2.3
func (a *ClosureDeallocator[T, P]) Deallocate(hints Hints)
func (*ClosureDeallocator[T, P]) SetArgument ¶ added in v1.2.3
func (a *ClosureDeallocator[T, P]) SetArgument(arg T)
type ClosureDeallocatorPool ¶ added in v1.2.3
type ClosureDeallocatorPool[T any, P interface { *T TraitHolder }] struct { // contains filtered or unexported fields }
func NewClosureDeallocatorPool ¶ added in v1.2.3
func NewClosureDeallocatorPool[T any, P interface { *T TraitHolder }]( deallocateFunc func(Hints, *T), ) *ClosureDeallocatorPool[T, P]
func (*ClosureDeallocatorPool[T, P]) Get ¶ added in v1.2.3
func (c *ClosureDeallocatorPool[T, P]) Get(args T) Deallocator
func (*ClosureDeallocatorPool[T, P]) Get2 ¶ added in v1.2.3
func (c *ClosureDeallocatorPool[T, P]) Get2(fn func(*T) T) Deallocator
type Config ¶ added in v1.2.1
type Config struct { // Allocator controls which allocator to use Allocator *string `toml:"allocator"` // CheckFraction controls the fraction of checked deallocations // On average, 1 / fraction of deallocations will be checked for double free or missing free CheckFraction *uint32 `toml:"check-fraction"` // FullStackFraction controls the fraction of full stack collecting in profile sampling // On average, 1 / fraction of allocations will be sampled with full stack information FullStackFraction *uint32 `toml:"full-stack-fraction"` // EnableMetrics indicates whether to expose metrics to prometheus EnableMetrics *bool `toml:"enable-metrics"` }
type CounterInteger ¶ added in v1.2.1
type Deallocator ¶ added in v1.2.1
type Deallocator interface { TraitHolder Deallocate(hint Hints) }
func ChainDeallocator ¶ added in v1.2.1
func ChainDeallocator(dec1 Deallocator, dec2 Deallocator) Deallocator
type FixedSizeAllocator ¶ added in v1.2.1
type FixedSizeAllocator interface {
Allocate(hint Hints) ([]byte, Deallocator, error)
}
type FuncDeallocator ¶ added in v1.2.1
type FuncDeallocator func(hints Hints)
func (FuncDeallocator) As ¶ added in v1.2.3
func (FuncDeallocator) As(target Trait) bool
func (FuncDeallocator) Deallocate ¶ added in v1.2.1
func (f FuncDeallocator) Deallocate(hints Hints)
type FunctionKey ¶ added in v1.2.1
type FunctionKey struct {
Name string
}
type HeapSampleValues ¶ added in v1.2.1
type HeapSampleValues struct { AllocatedObjects ShardedCounter[int64, atomic.Int64, *atomic.Int64] AllocatedBytes ShardedCounter[int64, atomic.Int64, *atomic.Int64] InuseObjects ShardedCounter[int64, atomic.Int64, *atomic.Int64] InuseBytes ShardedCounter[int64, atomic.Int64, *atomic.Int64] }
func (*HeapSampleValues) DefaultSampleType ¶ added in v1.2.1
func (h *HeapSampleValues) DefaultSampleType() string
func (*HeapSampleValues) Init ¶ added in v1.2.1
func (h *HeapSampleValues) Init()
func (*HeapSampleValues) SampleTypes ¶ added in v1.2.1
func (h *HeapSampleValues) SampleTypes() []*profile.ValueType
func (*HeapSampleValues) Values ¶ added in v1.2.1
func (h *HeapSampleValues) Values() []int64
type LeaksTracker ¶ added in v1.2.3
type LeaksTracker struct {
// contains filtered or unexported fields
}
func (*LeaksTracker) ReportLeaks ¶ added in v1.2.3
func (t *LeaksTracker) ReportLeaks(w io.Writer) (leaks bool)
type LeaksTrackingAllocator ¶ added in v1.2.3
type LeaksTrackingAllocator struct {
// contains filtered or unexported fields
}
func NewLeaksTrackingAllocator ¶ added in v1.2.3
func NewLeaksTrackingAllocator( upstream Allocator, tracker *LeaksTracker, ) (ret *LeaksTrackingAllocator)
func (*LeaksTrackingAllocator) Allocate ¶ added in v1.2.3
func (t *LeaksTrackingAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type LocationKey ¶ added in v1.2.1
type ManagedAllocator ¶ added in v1.2.3
type ManagedAllocator struct {
// contains filtered or unexported fields
}
func NewManagedAllocator ¶ added in v1.2.3
func NewManagedAllocator( upstream Allocator, ) *ManagedAllocator
func (*ManagedAllocator) Allocate ¶ added in v1.2.3
func (m *ManagedAllocator) Allocate(size uint64, hints Hints) ([]byte, error)
func (*ManagedAllocator) Deallocate ¶ added in v1.2.3
func (m *ManagedAllocator) Deallocate(slice []byte, hints Hints)
type MetricsAllocator ¶ added in v1.2.1
type MetricsAllocator struct {
// contains filtered or unexported fields
}
func NewMetricsAllocator ¶ added in v1.2.1
func NewMetricsAllocator( upstream Allocator, allocateBytesCounter prometheus.Counter, inuseBytesGauge prometheus.Gauge, allocateObjectsCounter prometheus.Counter, inuseObjectsGauge prometheus.Gauge, ) *MetricsAllocator
func (*MetricsAllocator) Allocate ¶ added in v1.2.1
func (m *MetricsAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type ProfileAllocator ¶ added in v1.2.1
type ProfileAllocator struct {
// contains filtered or unexported fields
}
func NewProfileAllocator ¶ added in v1.2.1
func NewProfileAllocator( upstream Allocator, profiler *Profiler[HeapSampleValues, *HeapSampleValues], fraction uint32, ) *ProfileAllocator
func (*ProfileAllocator) Allocate ¶ added in v1.2.1
func (p *ProfileAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type Profiler ¶ added in v1.2.1
type Profiler[T any, P interface { *T SampleValues }] struct { // contains filtered or unexported fields }
func NewProfiler ¶ added in v1.2.1
func NewProfiler[T any, P interface { *T SampleValues }]() *Profiler[T, P]
type RandomAllocator ¶ added in v1.2.3
type RandomAllocator struct {
// contains filtered or unexported fields
}
RandomAllocator calls upstream1 or upstream2 in certain probability
func NewRandomAllocator ¶ added in v1.2.3
func NewRandomAllocator( upstream1 Allocator, upstream2 Allocator, upstream2Fraction uint32, ) *RandomAllocator
func (*RandomAllocator) Allocate ¶ added in v1.2.3
func (r *RandomAllocator) Allocate(size uint64, hint Hints) ([]byte, Deallocator, error)
type ReadOnlyAllocator ¶ added in v1.2.3
type ReadOnlyAllocator struct {
// contains filtered or unexported fields
}
func NewReadOnlyAllocator ¶ added in v1.2.3
func NewReadOnlyAllocator( upstream Allocator, ) *ReadOnlyAllocator
func (*ReadOnlyAllocator) Allocate ¶ added in v1.2.3
func (r *ReadOnlyAllocator) Allocate(size uint64, hint Hints) ([]byte, Deallocator, error)
type SampleInfo ¶ added in v1.2.1
type SampleValues ¶ added in v1.2.1
type ShardedAllocator ¶ added in v1.2.1
type ShardedAllocator []Allocator
func NewShardedAllocator ¶ added in v1.2.1
func NewShardedAllocator(numShards int, newShard func() Allocator) ShardedAllocator
func (ShardedAllocator) Allocate ¶ added in v1.2.1
func (s ShardedAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type ShardedCounter ¶ added in v1.2.1
type ShardedCounter[T CounterInteger, A any, P interface { *A AtomicInteger[T] }] struct { // contains filtered or unexported fields }
func NewShardedCounter ¶ added in v1.2.1
func NewShardedCounter[T CounterInteger, A any, P interface { *A AtomicInteger[T] }](shards int) *ShardedCounter[T, A, P]
func (*ShardedCounter[T, A, P]) Add ¶ added in v1.2.1
func (s *ShardedCounter[T, A, P]) Add(v T)
func (*ShardedCounter[T, A, P]) Load ¶ added in v1.2.1
func (s *ShardedCounter[T, A, P]) Load() (ret T)
type SizeBoundedAllocator ¶ added in v1.2.1
type SizeBoundedAllocator struct {
// contains filtered or unexported fields
}
func NewSizeBoundedAllocator ¶ added in v1.2.1
func NewSizeBoundedAllocator(upstream Allocator, maxSize uint64, counter *atomic.Uint64) (ret *SizeBoundedAllocator)
func (*SizeBoundedAllocator) Allocate ¶ added in v1.2.1
func (s *SizeBoundedAllocator) Allocate(size uint64, hints Hints) ([]byte, Deallocator, error)
type StacktraceID ¶ added in v1.2.3
type StacktraceID uint64
func GetStacktraceID ¶ added in v1.2.3
func GetStacktraceID(skip int) StacktraceID
func (StacktraceID) String ¶ added in v1.2.3
func (s StacktraceID) String() string
type TraitHolder ¶ added in v1.2.3
Source Files ¶
- allocator.go
- c_allocator.go
- chain_deallocator.go
- checked_allocator.go
- class_allocator.go
- closure_deallocator.go
- config.go
- default.go
- fixed_size_allocator.go
- fixed_size_mmap_allocator.go
- fixed_size_sync_pool_allocator.go
- func_deallocator.go
- hints.go
- leaks_tracker.go
- leaks_tracking_allocator.go
- managed_allocator.go
- metrics_allocator.go
- mmap_linux.go
- profile_allocator.go
- profiler.go
- random_allocator.go
- read_only_allocator.go
- sharded_allocator.go
- sharded_counter.go
- size_bounded_allocator.go
- stacktrace.go
- trait.go
- unsafe.go
- utils.go
Click to show internal directories.
Click to hide internal directories.