Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
100 SC require 10KB GC Alloc
#1
Moving about 100 SplineController require 10 Kbyte GC Alloc in Refresh(); One needs 100B
From what I see the GC Alloc is produced in base.Refresh();

I do not want to create SplineController dynamically on the fly.
Is there any chance to have a SplineController option that exist permanenely at run time?
Or is there any other option available to prevent the GC's on a SC?

[Image: scgcalloc.jpg]
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#2
Of course the SplineController is persistent at runtime. The 100 bytes allocation are split by

a.) a check whether an event is bound to OnControlPointReached, 20 bytes, no way to improve that unless Unity opens up their API (VOTE here to support this!)
b.) once the event is bound, an EventData class is created and handed over to user's event handler, 80 Bytes. We consider optimizing this by reusing a single class instance

Edit: A way to get rid of the lasting 20 bytes is to cache the reflection call that checks for bound events (e.g. check only once after the controller starts playing). But that would force users to trigger a re-check after they bound an eventhandler. This would be very odd behaviour and against all C# event philosophies, but I'll sleep over this idea.
Reply
#3
Thanks for the information. I have voted for.
Or sleep two, but give it a try :-)
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply


Forum Jump: