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

x/mobile: memory ios #21489

Closed
gowinder opened this issue Aug 17, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@gowinder
Copy link

commented Aug 17, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8 darwin/amd64

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

GOARCH="amd64"
GOBIN="/usr/local/Cellar/go/1.8/libexec"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Mac/Code/golang"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gb/k1qql3113734cl6kpzgfzl2m0000gn/T/go-build278014438=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

i build a shadowsocks local proxy, at windows platform, it just use 5,6, top 8m memory, but when i use
gomobile bind -target=ios proxyproject/my/net
invoke the function in IOS network extension,
the memory of PacketTunnel start at 6m, and glow to 15 after use safari, 15m is the limit of network extension, when memory use 15m, ios will kill the PacketTunnel
why gomobile export function not release memory to system?
I do call runtime.GC(), but in windows platform it's ok, but IOS, memory keep growing.

What did you expect to see?

Is there any way to reduce memory on IOS, or return memory to system

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Aug 17, 2017

@gopherbot gopherbot added the mobile label Aug 17, 2017

@yamada95

This comment has been minimized.

Copy link

commented Sep 1, 2017

why gomobile export function not release memory to system?

Go will release memory and return them to the OS, but not immediately.

Is there any way to reduce memory on IOS, or return memory to system

You can call debug.FreeOSMemory() to tell GC to return memory, but it may not help much. I found debug.SetGCPercent(10) is more helpful.

I think you should make your code more memory efficient, you may also want to limit goroutine concurrency to make sure they will not eat up all your available memory.

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2017

As @serika00 says, the two tools available are debug.FreeOSMemory and debug.SetGCPercent.

Note that as this is a question, not a bug report, it shouldn't be on the issue tracker. Please see http://golang.org/wiki/Questions.

@crawshaw crawshaw closed this Sep 3, 2017

@gowinder

This comment has been minimized.

Copy link
Author

commented Sep 4, 2017

debug.SetGCPercent(10) is usefull, thanks

@golang golang locked and limited conversation to collaborators Sep 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.