mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-04-24 20:28:11 +08:00
chore: init gopsutil's Process direct from struct
This commit is contained in:
parent
2c09ce44f6
commit
e9c9d17a9b
@ -19,7 +19,7 @@ func init() {
|
|||||||
downloadBlip: atomic.NewInt64(0),
|
downloadBlip: atomic.NewInt64(0),
|
||||||
uploadTotal: atomic.NewInt64(0),
|
uploadTotal: atomic.NewInt64(0),
|
||||||
downloadTotal: atomic.NewInt64(0),
|
downloadTotal: atomic.NewInt64(0),
|
||||||
pid: os.Getpid(),
|
process: &process.Process{Pid: int32(os.Getpid())},
|
||||||
}
|
}
|
||||||
|
|
||||||
go DefaultManager.handle()
|
go DefaultManager.handle()
|
||||||
@ -33,7 +33,7 @@ type Manager struct {
|
|||||||
downloadBlip *atomic.Int64
|
downloadBlip *atomic.Int64
|
||||||
uploadTotal *atomic.Int64
|
uploadTotal *atomic.Int64
|
||||||
downloadTotal *atomic.Int64
|
downloadTotal *atomic.Int64
|
||||||
pid int
|
process *process.Process
|
||||||
memory uint64
|
memory uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +71,7 @@ func (m *Manager) Snapshot() *Snapshot {
|
|||||||
})
|
})
|
||||||
|
|
||||||
getMem := func() uint64 {
|
getMem := func() uint64 {
|
||||||
p, err := process.NewProcess(int32(m.pid))
|
stat, err := m.process.MemoryInfo()
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
stat, err := p.MemoryInfo()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user