On 05/12/2012 11:08 PM, Roman D. Boiko wrote:
On Saturday, 12 May 2012 at 20:28:34 UTC, Tobias Pankrath wrote:
1. If a struct is a field of heap allocated object, it will be
allocated and garbage collected. Only if it only exists on stack
(i.e., in method body), GC is not used.

As far as I can tell, it won't be allocated on it's own, since it is
stored in the garbage collected object as a value field. So using a
freelist would actually increase the overhead. You have to manage the
freelist and do the allocation of the containing object.
Sorry for confusion. In the first point I was trying to clarify that
using a struct doesn't mean that it is stack allocated, but that
statement was off-topic for the given context. Currently I consider my
first point to be useless, and the second one is not relevant in *my*
context, since I don't do many allocations of Location, as well as in a
majority of other contexts. As it is often the case, performance
optimization should be performed only when benchmarks show it is needed.


Well yes, but it seems to me that you are deliberately complicating the design in order to make it less efficient?

Reply via email to