I attempted to work with picture/gif, which prompted an excessive amount of reminiscence utilization for my venture and it wouldn’t be freed, and eventually I discovered that it was an issue with this library?
You’ll be able to check out the easy code under, he occupies an excessive amount of bodily reminiscence, and most of it’s sharing reminiscence, and even handbook gc can’t launch it, I exploit a software for prometheus to indicate the precise bodily reminiscence, which could be very irregular.
go model go1.20.11 linux/amd64
22.04.3-Ubuntu
bundle essential
import (
"bytes"
"fmt"
"github.com/prometheus/procfs"
"picture/gif"
"ntest/res"
"os"
"runtime"
"time"
)
func init() {
gif.DecodeAll(bytes.NewReader(res.GIF))
}
func essential() {
proc, _ := procfs.NewProc(os.Getpid())
for {
time.Sleep(1 * time.Second)
runtime.GC()
stat, _ := proc.Stat()
fmt.Println(float64(stat.ResidentMemory()) / 1024 / 1024)
}
}