mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Fix oomprofile heap snapshots with Go 1.27
This commit is contained in:
@@ -18,17 +18,7 @@ type stackRecord struct {
|
||||
Stack []uintptr
|
||||
}
|
||||
|
||||
type memProfileRecord struct {
|
||||
AllocBytes, FreeBytes int64
|
||||
AllocObjects, FreeObjects int64
|
||||
Stack []uintptr
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) InUseBytes() int64 {
|
||||
return r.AllocBytes - r.FreeBytes
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) InUseObjects() int64 {
|
||||
func (r *memProfileRecord) inUseObjects() int64 {
|
||||
return r.AllocObjects - r.FreeObjects
|
||||
}
|
||||
|
||||
@@ -336,12 +326,12 @@ func writeHeapProto(w io.Writer, profile []memProfileRecord, rate int64, default
|
||||
hideRuntime = false
|
||||
}
|
||||
|
||||
values[0], values[1] = scaleHeapSample(record.AllocObjects, record.AllocBytes, rate)
|
||||
values[2], values[3] = scaleHeapSample(record.InUseObjects(), record.InUseBytes(), rate)
|
||||
values[0], values[1] = scaleHeapSample(record.AllocObjects, record.allocBytes(), rate)
|
||||
values[2], values[3] = scaleHeapSample(record.inUseObjects(), record.inUseBytes(), rate)
|
||||
|
||||
var blockSize int64
|
||||
if record.AllocObjects > 0 {
|
||||
blockSize = record.AllocBytes / record.AllocObjects
|
||||
blockSize = record.allocBytes() / record.AllocObjects
|
||||
}
|
||||
builder.pbSample(values, locs, func() {
|
||||
if blockSize != 0 {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build (darwin || linux || windows) && !go1.27
|
||||
|
||||
package oomprofile
|
||||
|
||||
type memProfileRecord struct {
|
||||
AllocBytes, FreeBytes int64
|
||||
AllocObjects, FreeObjects int64
|
||||
Stack []uintptr
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) allocBytes() int64 {
|
||||
return r.AllocBytes
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) inUseBytes() int64 {
|
||||
return r.AllocBytes - r.FreeBytes
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build (darwin || linux || windows) && go1.27
|
||||
|
||||
package oomprofile
|
||||
|
||||
type memProfileRecord struct {
|
||||
ObjectSize int64
|
||||
AllocObjects, FreeObjects int64
|
||||
Stack []uintptr
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) allocBytes() int64 {
|
||||
return r.AllocObjects * r.ObjectSize
|
||||
}
|
||||
|
||||
func (r *memProfileRecord) inUseBytes() int64 {
|
||||
return r.inUseObjects() * r.ObjectSize
|
||||
}
|
||||
Reference in New Issue
Block a user