Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread drew
Actually, the new version I just posted is even worse: uncommenting the y[0] = nil line no longer allows memory to be freed. It really does seem like compiler optimizations are making this hard to reason about. On Thursday, December 22, 2016 at 1:08:13 PM UTC-5, dr...@pendo.io wrote: > > You may

Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread drew
Actually, the above version makes it even worse, as uncommenting the y[0] = nil line no longer causes memory to be freed. It really does look like compiler optimizations are making this hard to reason about. On Thursday, December 22, 2016 at 1:08:13 PM UTC-5, dr...@pendo.io wrote: > > You may be

Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread drew
You may be on to something about compiler optimizations, but unfortunately it doesn't seem that simple: https://play.golang.org/p/Qa-i5eiRZ_. It looks like using _ was confusing matters, so I switched to using a Println to force actual use of those variables. The issue still occurs with global

Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread Ian Lance Taylor
On Thu, Dec 22, 2016 at 9:16 AM, wrote: > It should be clear from the source code, but I'm using two calls to > runtime.GC() followed by runtime.ReadMemStats(). Oh, I see, sorry. My guess is that you are effectively testing the compiler's statement ordering. The compiler knows that calling All

Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread drew
It should be clear from the source code, but I'm using two calls to runtime.GC() followed by runtime.ReadMemStats(). On Thursday, December 22, 2016 at 12:06:13 PM UTC-5, Ian Lance Taylor wrote: > > On Thu, Dec 22, 2016 at 8:16 AM, > wrote: > > > > I was just toying around with pointers to slic

Re: [go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread Ian Lance Taylor
On Thu, Dec 22, 2016 at 8:16 AM, wrote: > > I was just toying around with pointers to slice elements, and I ended up > with this Go program: https://play.golang.org/p/D6e2SHEW1f. By the end of > the program, all references to memory in the main function are dropped, but > memory isn't freed after

[go-nuts] Simple Go program that doesn't seem to free memory as it should...

2016-12-22 Thread drew
Hi all, I was just toying around with pointers to slice elements, and I ended up with this Go program: https://play.golang.org/p/D6e2SHEW1f. By the end of the program, all references to memory in the main function are dropped, but memory isn't freed after a call to runtime.GC(). This happens bo