resonance-audio / resonance-audio-unity-sdk

Resonance Audio SDK for Unity
https://resonance-audio.github.io/resonance-audio/develop/unity/getting-started
Other
297 stars 38 forks source link

ResonanceAudioRoomManager generates garbage memory #2

Closed pschraut closed 6 years ago

pschraut commented 6 years ago

ResonanceAudioRoomManager.UpdateRoom() is called by ResonanceAudioRoom(s). The method allocates a RoomEffectsRegion object every call, causing garbage memory to be created.

It's recommended to write per-frame allocation free code, if performance is a concern, such as in interactive applications that have to run at 60 or 90 frames per second.

Reproduce

Observe in "CPU Usage" profiler that ResonanceAudioRoom.Update() allocates 224 bytes every frame. It's tracked in the "GC Alloc" column.

Expected Code that runs every frame should not allocate memory, which causes GC collection eventually.

There are other methods in ResonanceAudioRoomManager that cause GC allocs as well, such as "RemoveRoom". Ideally, these should also cause no allocations.

anokta commented 6 years ago

Another great catch, Peter! We're currently looking into this. Should be fixed by the next update.

Thanks!

ilmarioranen commented 6 years ago

I'd like to also point out that this method call also creates 56b per-frame GC alloc overhead. Noticed with with deep profiling (tested with Editor playmode, not actual build yet): AudioSettings.GetSpatializerPluginName()

String concat or such, maybe? Should be avoidable allocations.

anokta commented 6 years ago

Fixed in v1.1.0.