Hi Go community,

I am wondering if a method with the pointer receiver keeps the receiver 
instance from garbage collected.

To put the idea into a code example

```
type counter struct {
c int
}

func (c *counter) next() int {
c.c = c.c + 1
return c.c
}

func getNextFunc() func () int {
// Question: will c be garbage collected after the function retruns?
c := &counter{}
return c.next
}
```


-- 
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/434878c2-6ffe-4cc9-a0d4-3de8581b7138n%40googlegroups.com.

Reply via email to