in addition to the original question, I have found a way to get the 
following memstats in a few seconds:

# runtime.MemStats
# Alloc = 22267160
# TotalAlloc = 42133760
# Sys = 8852177152
# Lookups = 0
# Mallocs = 1041166
# Frees = 805749
# HeapAlloc = 22267160
# HeapSys = 67108864
# HeapIdle = 42459136
# HeapInuse = 24649728
# HeapReleased = 41943040
# HeapObjects = 235417
# Stack = 0 / 8778907648
# MSpan = 384064 / 393216
# MCache = 5016 / 16384
# BuckHashSys = 1452992
# GCSys = 3676424
# OtherSys = 621624
# NextGC = 27397520
# LastGC = 1627069277209120125

7 threadcreate
7 goroutine

Total allocations of golang program are about 42MB, but go runtime takes 
8GB for in OS thread stacks.
What am I doing wrong?

Thanks!

On Monday, October 4, 2021 at 8:18:41 PM UTC-7 Renat Idrisov wrote:

> Hi All,
> we use cgo on Linux, because of mips bytecode that is not supported by 
> main go compiler.
> golang version is 1.16.5, latest release didn't tried. Writing here to 
> make sure what we see is a bug.
>
> The application is running for a few days, alive allocations are less than 
> 100MB:
> # Alloc = 36761056
> # TotalAlloc = 122637932112
>
> however this number keep growing until it got killed by OOM:
> # Sys = 852037904
> # Stack = 0 / 637796352
>
> the number of OS threads is not high, all counts look very modest:
> Count Profile
> 1810 allocs
> 0 block
> 0 cmdline
> 18 goroutine
> 1810 heap
> 0 mutex
> 0 profile
> 8 threadcreate
> 0 trace
>
> what can I do to prevent it from consuming that much stack and crashing?
>
> complete memstats below:
> # runtime.MemStats
> # Alloc = 36761056
> # TotalAlloc = 122637932112
> # Sys = 852037904
> # Lookups = 0
> # Mallocs = 359316187
> # Frees = 359262165
> # HeapAlloc = 36761056
> # HeapSys = 201326592
> # HeapIdle = 161890304
> # HeapInuse = 39436288
> # HeapReleased = 137854976
> # HeapObjects = 54022
> # Stack = 0 / 637796352
> # MSpan = 294984 / 376832
> # MCache = 5016 / 16384
> # BuckHashSys = 3459520
> # GCSys = 8067352
> # OtherSys = 994872
> # NextGC = 71737968
> # LastGC = 1633401481045016063
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/613fc819-aad6-4adb-bac1-149593282cc0n%40googlegroups.com.

Reply via email to