Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image: Massive Ram usage on image.NewRGBA #46732

Closed
MR-AliHaashemi opened this issue Jun 14, 2021 · 3 comments
Closed

image: Massive Ram usage on image.NewRGBA #46732

MR-AliHaashemi opened this issue Jun 14, 2021 · 3 comments
Milestone

Comments

@MR-AliHaashemi
Copy link

@MR-AliHaashemi MR-AliHaashemi commented Jun 14, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.5 windows/amd64

Does this issue reproduce with the latest release?

As I tested with 1.14.15 and 1.15.13, in 1.15 there was the exact same issue but in 1.14 it was less visible

What operating system and processor architecture are you using (go env)?

Windows 10 Pro 64bit (version 21H1)
Also code checked on Ubuntu 20.04 btw

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\mrali\AppData\Local\go-build
set GOENV=C:\Users\mrali\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\mrali\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\mrali\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.5
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\mrali\Desktop\Projects\LlamaNiteReWrite\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\mrali\AppData\Local\Temp\go-build3682471824=/tmp/go-build -gno-record-gcc-switches

What did you do?

A small part of the code (also the main issue) was something like this:
https://play.golang.org/p/0mkjppbKZVp

What did you expect to see?

I expected 0 ram usage because it was useless at that moment and function was closed,
Also, yes I can accept the first ~60 MiB Ram usage, but the second time I don't think could be normal

What did you see instead?

The first time used ~60 MiB ram even function was closed and I didn't use that image,
The second time it used ~60 MiB more ram, And Third, Fourth, ... time had the same usage as the second time.

What you want now?

I am a newbie Go developer, so I don't know a lot of things...
If there is a way to fix my code, please suggest to I use it, I have more than 1GB Ram usage only because of this.
In my opinion, it would be cool if something like .Close() to force removing the whole image from memory be added in the next updates, or... I don't know...

Thanks for reading and helps.

@gopherbot gopherbot added this to the Unreleased milestone Jun 14, 2021
@MR-AliHaashemi MR-AliHaashemi changed the title x/image: Massive Ram usage on image.NewRGBA image: Massive Ram usage on image.NewRGBA Jun 14, 2021
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jun 14, 2021

This seems to be the GC working as expected, if you really need the memory you can force GC runs

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

Loading

@seankhliao seankhliao closed this Jun 14, 2021
@MR-AliHaashemi
Copy link
Author

@MR-AliHaashemi MR-AliHaashemi commented Jun 14, 2021

Force running GC will not do anything.
I tried a lot of things.
but none of them worked!
that's why i opened this issue.

but anyways, thanks.
have a nice day.

Loading

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jun 14, 2021

forcing GC does free up space:

$ GODEBUG=gctrace=1 ./testrepo-473
gc 1 @0.003s 4%: 0.13+0.24+0.002 ms clock, 0.54+0.062/0.080/0.17+0.011 ms cpu, 56->56->56 MB, 57 MB goal, 4 P
gc 2 @5.016s 0%: 0.017+0.19+0.003 ms clock, 0.071+0.084/0.085/0.020+0.012 ms cpu, 112->112->56 MB, 113 MB goal, 4 P (forced)
gc 3 @5.017s 0%: 0.023+0.30+0.002 ms clock, 0.093+0/0.10/0.097+0.008 ms cpu, 56->56->0 MB, 112 MB goal, 4 P (forced)
gc 4 @5.017s 0%: 0.023+0.70+0.022 ms clock, 0.095+0/0.15/0.60+0.090 ms cpu, 0->0->0 MB, 4 MB goal, 4 P (forced)
gc 5 @10.029s 0%: 0.033+0.38+0.077 ms clock, 0.13+0.21/0.18/0.15+0.31 ms cpu, 56->56->56 MB, 57 MB goal, 4 P
gc 6 @10.030s 0%: 0.029+0.22+0.005 ms clock, 0.11+0/0.16/0.28+0.022 ms cpu, 56->56->0 MB, 112 MB goal, 4 P (forced)
gc 7 @10.031s 0%: 0.052+0.42+0.004 ms clock, 0.21+0/0.18/0.64+0.016 ms cpu, 0->0->0 MB, 4 MB goal, 4 P (forced)
gc 8 @15.016s 0%: 0.018+0.21+0.002 ms clock, 0.075+0.090/0.081/0.032+0.010 ms cpu, 56->56->56 MB, 57 MB goal, 4 P (forced)
gc 9 @15.016s 0%: 0.033+0.12+0.001 ms clock, 0.13+0/0.12/0.051+0.006 ms cpu, 56->56->0 MB, 112 MB goal, 4 P (forced)
gc 10 @15.017s 0%: 0.027+0.086+0.002 ms clock, 0.10+0/0.069/0.086+0.008 ms cpu, 0->0->0 MB, 4 MB goal, 4 P (forced)
gc 11 @20.019s 0%: 0.020+0.15+0.062 ms clock, 0.080+0.093/0.038/0.057+0.25 ms cpu, 56->56->56 MB, 57 MB goal, 4 P
gc 12 @20.019s 0%: 0.028+0.077+0.002 ms clock, 0.11+0/0.069/0.11+0.008 ms cpu, 56->56->0 MB, 112 MB goal, 4 P (forced)
gc 13 @20.020s 0%: 0.033+0.094+0.001 ms clock, 0.13+0/0.052/0.090+0.006 ms cpu, 0->0->0 MB, 4 MB goal, 4 P (forced)

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants