go icon indicating copy to clipboard operation
go copied to clipboard

runtime/cgo: under linux/arm7, cgo will occupy about 1g of memory, and static/dynamic will be generated

Open aadog opened this issue 2 years ago • 6 comments

What version of Go are you using (go version)? 1.17-1.93

$ go version 
go version go1.19.3 windows/amd64

Does this issue reproduce with the latest release?

yes

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

windows cross compile cgo library to arm7

What did you do?

windows cross compile cgo library to arm7

What did you expect to see?

The memory usage is below 5m

What did you see instead?

The memory usage is about 1g

There is only a simple hello, compile static/dynamic, it will happen after calling with qt

aadog avatar Dec 09 '22 15:12 aadog

real or virtual memory? where does the 5m number come from?

seankhliao avatar Dec 09 '22 15:12 seankhliao

virtual memory,5m is an export add func, the estimated maximum memory,

After I have confirmed many times, this happens on the export of cgo. As long as there is an export, a simple addin number will have 1g (after being statically linked, or after dlopen)

aadog avatar Dec 10 '22 04:12 aadog

The 1g memory of the development board is fully occupied in an instant, and the armel-based linux

aadog avatar Dec 10 '22 04:12 aadog

Could you please provide a reproducer (steps and the source code)? That'll help a lot in debugging this on our end. Thanks.

mknyszek avatar Dec 21 '22 20:12 mknyszek

@mknyszek Just simply write an export function, such as add,The problem seems to come from the compiler or the linker, as long as cgo is installed, 1g of virtual memory will be sold immediately

aadog avatar Dec 22 '22 08:12 aadog

The necessary condition is that arm linux, go as a static or dynamic library

aadog avatar Dec 22 '22 08:12 aadog

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

gopherbot avatar Jan 26 '23 13:01 gopherbot