Open yourchanges opened 4 years ago
图是heap inuse_space, heap 对象数 一直加,没见降
golang 1.13.5 centos 6 64位
顶,我也发现了这个问题
解决了吗
go version
go version go1.13.3 darwin/amd64
go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="==security_stuff=="
GOENV="==security_stuff=="
GOEXE=""
GOFLAGS=" -mod="
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="==security_stuff=="
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="==security_stuff=="
I did profiling to next code and the result, I got chart of the memory allocated. So i think this library haven't memory leak it's my concluding.
package main
import (
"bytes"
"fmt"
"github.com/chai2010/webp"
_ "github.com/mkevac/debugcharts"
"image/jpeg"
"io/ioutil"
"log"
"net/http"
_ "net/http/pprof"
"time"
)
func main() {
go func() {
http.ListenAndServe(":3030", nil)
}()
i := 0
for {
time.Sleep(time.Second / 10)
imgData, err := ioutil.ReadFile("test2.jpeg")
img, err := jpeg.Decode(bytes.NewBuffer(imgData))
if err != nil {
log.Println(err)
}
output, err := webp.EncodeRGBA(img, 80)
if err != nil {
log.Println(err)
}
if output != nil {
}
fmt.Println("Save output.webp ok", i)
i++
}
}
I create a simple http server do convert a jpg to webp
here is the sample code:
main.go
运行一段时间后, 内存分析图:
查看 相关源代码: