mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Alpha (#490)
* feat: add memory status for snapshot * feat: add memory status for snapshot
This commit is contained in:
parent
eb07aafce8
commit
36b3581389
|
@ -1,6 +1,7 @@
|
|||
package statistic
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -61,10 +62,17 @@ func (m *Manager) Snapshot() *Snapshot {
|
|||
return true
|
||||
})
|
||||
|
||||
getMem := func() uint64 {
|
||||
var memStats runtime.MemStats
|
||||
runtime.ReadMemStats(&memStats)
|
||||
return memStats.StackInuse + memStats.HeapInuse + memStats.HeapIdle - memStats.HeapReleased
|
||||
}
|
||||
|
||||
return &Snapshot{
|
||||
UploadTotal: m.uploadTotal.Load(),
|
||||
DownloadTotal: m.downloadTotal.Load(),
|
||||
Connections: connections,
|
||||
Memory: getMem(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,4 +100,5 @@ type Snapshot struct {
|
|||
DownloadTotal int64 `json:"downloadTotal"`
|
||||
UploadTotal int64 `json:"uploadTotal"`
|
||||
Connections []tracker `json:"connections"`
|
||||
Memory uint64 `json:"memory"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user