I’m noticing that there is GC allocation when calling DSP.getMeteringInfo, as shown in the (deep) profile below:
I’ve cached the variables that I can on my side, and so the code is simply just this now:
void LateUpdate() {
m_VoiceEventInstanceDSP.getMeteringInfo(out inputInfo, IntPtr.Zero);
}
For something that is typically run frequently, it would be great if this could be made to not allocate.
Thanks for pointing the allocation out, I can definitely see what you mean regarding the frequency the method is usually called with. I’ve added your suggestion to our internal improvement tracker.
1 Like
Thanks, that would be great as we are hoping to go to production with our title before long.
1 Like
Just to follow up on this, if you’re willing to modify the FMOD Unity integration code, you can swap usages of the out
keyword for ref
for DSP.getMeteringInfo()
, and it should remove the GC allocation. You’d also need to make sure to initialize any DSP_METERING_INFO
structs with new FMOD.DSP_METERING_INFO()
since you’re passing them to the function instead of having them passed out.
For just the code in the FMOD Unity integration (exact lines may differ based on your version), you’d need to modify the following:
- fmod.cs, lines ~3434 - ~3444: change any usages of
out
to ref
for all getMeteringInfo
overloads
- RuntimeManager.cs, lines ~721 - ~722: add struct initialization and change keyword usage
- EditorUtils.cs, lines ~816 - ~817: add struct initialization and change keyword usage
Thanks for the update! I am assuming that these improvements will make it in to an official update? We regularly update FMOD to the latest version so this would be a bit cumbersome to remember to apply every time.
The improvements are scheduled to be included in an official update, yes. However, since we aim to maintain code compatibility between minor API versions, it’s unlikely to be until our next major version update (2.04) since the keyword change would necessitate code changes on the part of people using DSP_METERING_INFO structs in their own code.