Re: [go-nuts] Do we need to drain a closed channel ?

2024-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2024 at 6:26 AM Shubha Acharya
 wrote:
>
> I have been working with buffered channels. I have stumbled upon a scenario 
> where buffered channel will be closed and the receivers of the channel 
> terminates before consuming all the elements in the buffer. So my question is 
> will there be any issue regarding Garbage Collection of channel which 
> eventually leads to memory or resource leaks because of the left out items in 
> the buffer? or any other concerns that I must be aware of?

No more than, say, a slice.  An unreferenced channel will be garbage
collected, which will remove references to any objects in the channel
buffer.  If those objects have no other references, they too will be
garbage collected.

Ian

-- 
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/CAOyqgcU6ogchtswNFtj%3Dsjry4pJZsioZBxANGZn3%2B2xz4XdFJg%40mail.gmail.com.


[go-nuts] Do we need to drain a closed channel ?

2024-03-01 Thread Shubha Acharya
Hey,

I have been working with buffered channels. I have stumbled upon a scenario 
where buffered channel will be closed and the receivers of the channel 
terminates before consuming all the elements in the buffer. So my question 
is will there be any issue regarding Garbage Collection of channel which 
eventually leads to memory or resource leaks because of the left out items 
in the buffer? or any other concerns that I must be aware of?

-- 
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/58931f04-bd6b-4e37-bacf-d1ca285f24f6n%40googlegroups.com.