BTW, how are you measuring RSS?  That is a trick all by itself!  See 
https://groups.google.com/g/golang-nuts/c/LsOYrYc_Occ/m/LbjLAsL6BwAJ

Regards,
Mike

golang-nuts@googlegroups.com wrote on 08/23/2020 11:04:47 AM:

> From: Manish R Jain <manishrj...@gmail.com>
> To: "golang-nuts" <golang-nuts@googlegroups.com>
> Date: 08/23/2020 11:04 AM
> Subject: [EXTERNAL] [go-nuts] Mysterious RSS memory spike
> Sent by: golang-nuts@googlegroups.com
> 
> Hey Gophers,
> 
> I'm puzzled by a mysterious RSS memory spike in my Go program, when 
> all memory allocations are happening via Cgo. I assert that there 
> are no memory leaks in the program. And have written another C 
> program with similar logic which does NOT show RSS memory spiking. 
> So, I suspect this is something to do with Go memory.
> 
> Program:
> 
> https://github.com/dgraph-io/ristretto/pull/186
> 
> This PR creates a Go memtest program, which does this:
> - Uses z.Calloc and z.Free to allocate Go struct (S) and a byte 
> slice inside it. All allocations are happening in Cgo, and being 
> type casted into Go. No allocations are happening in Go (except a 32
> MB fill slice).
> - z.NumAllocBytes is tracking memory allocated and freed by these calls.
> - Increases memory usage to 16 GB (as reported by z.NumAllocBytes).
> - Decreases it back to 1 GB.
> - Repeats this cycle.
> - On Ctrl+C, it deallocates everything and asserts that Cgo memory 
> allocated is zero.
> 
> I was concerned about memory fragmentation, so created a very 
> similar C program which does the same thing (memtestc).
> 
> Please feel free to run either of the Go or C programs. They should 
> compile and run easily.
> 
> Behavior:
> 
> Run the program with: `go build . && ./memtest` . Go pprof heap 
> shows 32 MB used, to account for the fill slice. However, RSS 
> reported keeps roughly increasing every cycle.
> 
> I'm using Go 1.14.4 and on it, RSS jumps to 22GB after a few cycles. 
> memtestc (C equivalent, compiled with gcc) does not show this 
> behavior. The RSS goes down to 1GB-ish every cycle.
> 
> Any clues why the RSS is much higher than expected in Go and keeps 
> climbing in Go?
> 
> ?
> Manish
> Founder, https://dgraph.io
> [image removed] 
> -- 
> 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/a592db0482f1843c694a9486379a47dd%40frontapp.com.

-- 
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/OFD256528A.E55B2BFE-ON852585CD.00651CB3-852585CD.0065262F%40notes.na.collabserv.com.

Reply via email to