mirror of
https://github.com/YuzuZensai/TrollSSH.git
synced 2026-09-14 00:59:02 +00:00
🚀 perf: Performance and Memory optimization
This commit is contained in:
@@ -28,6 +28,8 @@ func readFrameFile(filename string) (*frameFile, error) {
|
||||
data, err := os.ReadFile(filename)
|
||||
return &frameFile{data: data}, err
|
||||
}
|
||||
|
||||
_ = syscall.Madvise(data, syscall.MADV_RANDOM)
|
||||
return &frameFile{
|
||||
data: data,
|
||||
cleanup: func() error {
|
||||
@@ -35,3 +37,10 @@ func readFrameFile(filename string) (*frameFile, error) {
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f *frameFile) dropResident() {
|
||||
if f == nil || f.cleanup == nil || len(f.data) == 0 {
|
||||
return
|
||||
}
|
||||
_ = syscall.Madvise(f.data, syscall.MADV_DONTNEED)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user