Re: [go-nuts] For range loop variable passing by reference to go routine causes memory leak

2022-10-08 Thread davy zhang
Thank you so much for pointing this out. I didn't realize that map
won't shrink in go, that's pretty counter intuitive.

I also found the issue here:
https://github.com/golang/go/issues/20135

It looks like the right direction.

On Sun, Oct 9, 2022 at 2:29 PM wagner riffel  wrote:
>
> On 08/10/2022 22:56, davy zhang wrote:
> > Original post on stackoverflow:
> >
> > https://stackoverflow.com/questions/73985794/for-range-loop-variable-passing-by-reference-to-go-routine-causes-memory-leak
> >
> >
> > Code for reproducing the problem:
> >
> > https://go.dev/play/p/7Xzx1Aauzhh
> >
> > go version go1.19 darwin/amd64
> >
> > go tool pprof http://localhost:6060/debug/pprof/heap
> >
> > func1 is leaking
> >
> > https://i.stack.imgur.com/LTXHn.png 
> >
> > Is there any reason for this leaking?
> >
> >
> > Thank you for any input
> >
>
> I don't think it's related with for-range loops, both should "leak"
> the same, I bet that's tMap, currently in Go maps do not shrink, even
> if you delete keys. One way to reduce memory usage of a long-living
> map is to at some threshold copy over all its elements into a new map,
> and set the old to map to this copy, then the old map, if not
> referenced elsewhere, will eventually be gc'ed and cleaned up.
>
> -w
>

-- 
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/CABAC%3DhuQYcch3AOjhPKvQbwGacUd%3DjYgtTbE_u_dj0kFkwYd8w%40mail.gmail.com.


Re: [go-nuts] For range loop variable passing by reference to go routine causes memory leak

2022-10-08 Thread 'wagner riffel' via golang-nuts

On 08/10/2022 22:56, davy zhang wrote:

Original post on stackoverflow:

https://stackoverflow.com/questions/73985794/for-range-loop-variable-passing-by-reference-to-go-routine-causes-memory-leak


Code for reproducing the problem:

https://go.dev/play/p/7Xzx1Aauzhh

go version go1.19 darwin/amd64

go tool pprof http://localhost:6060/debug/pprof/heap

func1 is leaking

https://i.stack.imgur.com/LTXHn.png 

Is there any reason for this leaking?


Thank you for any input



I don't think it's related with for-range loops, both should "leak"
the same, I bet that's tMap, currently in Go maps do not shrink, even
if you delete keys. One way to reduce memory usage of a long-living
map is to at some threshold copy over all its elements into a new map,
and set the old to map to this copy, then the old map, if not
referenced elsewhere, will eventually be gc'ed and cleaned up.

-w

--
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/d227d9f0-90e1-fb62-2925-9a4729036708%40104d.net.


[go-nuts] How Go Compiler oprimize method with value or pointer receiver/functions

2022-10-08 Thread Richiise Nugraha
Hi all, I have a few question regarding Go compiler optimizations.

How Go Compiler (gc) optimize methods with value or pointer receiver (or 
functions)?
Does a method with value receiver always create a copy of data to its stack 
or the copy happend if there's a write attempt to it (CoW, or used fields)?
>From what I know it always create a copy of data with DUFFCOPY, but I am 
not sure if there's another cases.

For example I have 2 methods. Value, pointer receiver, respectively:
[Link: https://godbolt.org/z/dhTxez5jK]
TEXT main.Donothing(SB), NOSPLIT|ABIInternal, $0-216
TEXT main.PtrDonothing(SB), NOSPLIT|ABIInternal, $0-8

Function `main.Donothing` has a big stack size compared `main.PtrDonothing`
And how does that affect inline budget

Thank you.

-- 
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/d087e77b-788b-4e92-8eee-6179af6b3f2cn%40googlegroups.com.


Re: [go-nuts] golang-announce rss feed

2022-10-08 Thread Ferdy
For anyone who might be interested;
https://googlegroups2rss.ferdypruis.dev/rss/golang-announce.xml.rss

I generate this feed myself by scraping the group.



On Thursday, July 29, 2021 at 9:01:19 PM UTC+2 Sebastien Binet wrote:

>
> Jul 28, 2021 18:02:06 Ferdy : 
>
> > Up until this morning I had the golang-announce group as an RSS feed in 
> my teams channel, to keep us updated on new releases, using this url 
> > 
> https://groups.google.com/forum/feed/golang-announce/msgs/rss_v2_0.xml?num=5 
> > 
> > But it seems this feature has just stopped working. 
> > 
> > Any other ways of getting the golang-announce mailinglist as an RSS feed 
> from somewhere, now Google Groups seems to have stopped supporting it? 
> > 
> > The @golang Twitter feed might be al alternative source, but Twitter 
> doesn't officially support RSS either. 
>
> One can use nitter for that: 
> https://nitter.net/ 
> https://nitter.net/golang/rss 
>
> (Or one of its other mirrors) 
>
> -s 
>
> > -- 
> > 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...@googlegroups.com. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/5effacca-84c1-46ac-9ea6-015e4c0daf16n%40googlegroups.com[https://groups.google.com/d/msgid/golang-nuts/5effacca-84c1-46ac-9ea6-015e4c0daf16n%40googlegroups.com?utm_medium=email_source=footer]
>  
> 
> . 
>

-- 
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/5688f445-2e34-4576-97ff-42e6df84cfdan%40googlegroups.com.