I'm implementing a bounding volume hierarchy in F#. Since it would be for a game, I want the garbage collector to be as quick and infrequent as possible.It seems though that I may have to pull some whacky tricks, probably pre-allocating everything. That means that I can't have many things immutable, and that I have to know up front how large my tree will be -- a major annoyance.I'll probably end up biting the bullet and doing just that (or maybe just go back to C++), but for the record, are trees inherently bad for GC performance? They would seem to be, considering the mark stage would have to traverse a lot of nodes.
Are tree structures inherently bad for mark-and-sweep garbage collector performance?
game development;garbage collection;trees
I understand that you are concerned about this issue not because you suffer from the premature optimization syndrome, but because you are worried that this potential performance issue might need to be taken into consideration in order to make the right choices of technologies in the very beginning of the project. If that is your concern, there is no answer oh, yes, that's really going to kill the GC or no, don't worry, everything will be fine that you should really depend on. Just implement a test scenario, and see for yourself how it performs.(My guess is that there will be no problem whatsoever. Even in conditions 10x worse than your projected usage.)