Documentation
¶
Index ¶
- func EstimateMatrixMemory(rows, cols int) uint64
- func FormatBytes(bytes uint64) string
- func MonitorGoroutines(duration time.Duration, interval time.Duration) []int
- func WriteHeapProfile(filename string) error
- type LeakCheckpoint
- type LeakDetector
- type LeakReport
- type MemoryProfiler
- type MemorySnapshot
- type MemorySummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateMatrixMemory ¶
EstimateMatrixMemory estimates memory usage for a matrix
func FormatBytes ¶
FormatBytes formats bytes in human-readable format
func MonitorGoroutines ¶
MonitorGoroutines monitors goroutine count over time
func WriteHeapProfile ¶
WriteHeapProfile writes a heap profile to file
Types ¶
type LeakCheckpoint ¶
type LeakCheckpoint struct {
Label string
Timestamp time.Time
Goroutines int
MemAlloc uint64
Leaked bool
Message string
}
LeakCheckpoint represents a leak detection checkpoint
type LeakDetector ¶
type LeakDetector struct {
// contains filtered or unexported fields
}
LeakDetector detects goroutine and memory leaks
func NewLeakDetector ¶
func NewLeakDetector() *LeakDetector
NewLeakDetector creates a new leak detector
func (*LeakDetector) CheckGoroutines ¶
func (ld *LeakDetector) CheckGoroutines(label string) LeakCheckpoint
CheckGoroutines checks for goroutine leaks
func (*LeakDetector) CheckMemory ¶
func (ld *LeakDetector) CheckMemory(label string, threshold float64) LeakCheckpoint
CheckMemory checks for memory leaks after GC
func (*LeakDetector) GetReport ¶
func (ld *LeakDetector) GetReport() LeakReport
GetReport returns a summary of all checkpoints
type LeakReport ¶
type LeakReport struct {
InitialGoroutines int
InitialMemory uint64
Checkpoints []LeakCheckpoint
Leaks []LeakCheckpoint
HasLeaks bool
}
LeakReport summarizes leak detection results
func DetectLeaksInFunc ¶
func DetectLeaksInFunc(name string, fn func()) LeakReport
DetectLeaksInFunc runs a function and checks for leaks
type MemoryProfiler ¶
type MemoryProfiler struct {
// contains filtered or unexported fields
}
MemoryProfiler tracks memory usage during operations
func NewMemoryProfiler ¶
func NewMemoryProfiler() *MemoryProfiler
NewMemoryProfiler creates a new memory profiler
func (*MemoryProfiler) Checkpoint ¶
func (mp *MemoryProfiler) Checkpoint(label string)
Checkpoint records memory state at a specific point
func (*MemoryProfiler) Start ¶
func (mp *MemoryProfiler) Start(label string)
Start begins memory profiling
func (*MemoryProfiler) Stop ¶
func (mp *MemoryProfiler) Stop() MemorySummary
Stop ends profiling and returns summary
type MemorySnapshot ¶
type MemorySnapshot struct {
Label string
Timestamp time.Time
AllocBytes uint64
TotalAlloc uint64
HeapAlloc uint64
HeapObjects uint64
NumGC uint32
}
MemorySnapshot represents memory state at a point in time
type MemorySummary ¶
type MemorySummary struct {
InitialAlloc uint64
FinalAlloc uint64
PeakAlloc uint64
TotalAllocated uint64
NumGCs uint32
Measurements []MemorySnapshot
}
MemorySummary contains profiling results
func ProfileFunc ¶
func ProfileFunc(name string, fn func()) MemorySummary
ProfileFunc profiles memory usage of a function