== Quote from Walter Bright (newshou...@digitalmars.com)'s article > dsimcha wrote: > > In this case, foo.myInvariantArray goes out of scope when foo() returns. > > When > > bar() allocates an array, it's entirely possible that the GC will give > > bar.myArray > > the same memory address as foo.myArray had. In this case, if you're only > > using > > stack bits to handle memoization, you're screwed. > That's the beauty of a garbage collector <g>. The bits will include a > reference to the immutable data, which the gc will see, and so the gc > will not reclaim that data.
Good point, the bits in the internal memoization AA will contain a reference. I forgot about that. This leads to another problem, though: Wouldn't this cause a lot of soft memory leaks, since you're holding references to stuff that's otherwise no longer needed?