-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting value for FloatVariable is causing GC allocations and slower execution #154
Comments
It's because every time you assign a |
Ahh, that makes sense. I didn't expect I also noticed that the GC allocations happen because "enable debug" is on in Preferences. Turning off "enable debug" gets rid of most of the allocations, and gave comparable performance to using |
I had one time the bad idea of setting the player's input every frame on a couple of My advise would be not to use SO when you need something to be updated every frame. |
The GC allocations are probably coming from GameEventBase's StackTrace feature. These allocations only happen in the Editor. |
In one of my MonoBehaviours, I am updating a
FloatVariable
everyUpdate
.However, I am noticing that this is causing the
Update
for the function to be much slower than if I had just set a float.With the line
myFloatVariable.Value = myFloat
, the Update function takes 0.54ms to complete and has a bunch of GC allocations:Setting only the float itself is significantly less time:
Anyone know why this might be the case?
Thanks!
The text was updated successfully, but these errors were encountered: