Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

Memory Leak with Unity Integration on OS X Builds

0 votes

There seems to be a memory leak or at least a mishandling of memory in the WWise Unity Integration on OS X builds. It may be related to calling AkSoundEngine.SetRTPCValue from a script but I can't seem to narrow it down. I'm using WWise v2015.1.3 with Unity 5.2.2p4 with the latest WWise Unity Integration 2015.1.3 - Unity 4/5 (Stable). I included links to two simple project builds I made, one for Windows (x86) and one for OS X (x86). The builds were made with the Sample WWise Project and use the Engine sounds. The engine sound will be playing by default and if you press "I" on your keyboard you can up the iterations of RPM RTPC function calls per frame. On Windows (specifically I'm testing with Windows 10 x64) the memory usage is initially about 20 MB and after increasing the iterations of RTPC calls the memory usage goes up to about 60 MB and stays around 60 MB even with 100000 calls per frame. On OS X (specifically I'm testing with OS X v10.11 El Capitan) the memory usage initially is about 20 MB and then jumps up to about 700 MB and after increasing the iterations of RTPC calls the memory usage jumps up to about 1.05 GB and the stays around there even with 100000 calls per frame. It just seems bizarre to me that the OS X build takes up so much more memory. This is causing a big issue for me with another bigger project I am developing since it seems like calling RTPC functions leaks memory until the application crashes. I'm just looking for input on this or if there is a workaround I could try. Also is anyone else experiencing issues like this? Thanks for any help :)

 

OS X Build: http://survivethedistance.com/wwisebugs/Mac.zip

Windows Build: survivethedistance.com/wwisebugs/Windows.zip

asked Nov 18, 2015 in General Discussion by Jordan H. (150 points)

2 Answers

0 votes
Hi Jordan,

I took a look with Instruments at the Mac app you provided. Prior to pressing the Play button, is there any call done to the Wwise API ? What I can see first is that before loading the Unity scene, the app seems to leak a bit already (few hundreds of bytes mainly from libmono.0.dylib). Once the play button is pressed, the memory usage rises above the 1GB as you mentioned but I did not have to change the number of RTPC iterations to reach this usage amount, leaving the default value of 1 was sufficient. Anyways, after quitting the app, a leak of about 37MB is present, the rest is not leaked per se according to Instruments and seems to be destroyed properly at the end of the application .

As for the amount of memory used by the Mac app vs the Windows one, I will try to investigate but :
-Can you provide a code snippet (or better yet, your project or a relevant subset of it) of your script where you call the SetRTPC API ?
-Do you use any string conversion when calling the RTPC API (such as AKPLATFORM::AkMacConvertString that are platform specific in your code) ?

Thanks,

Arnaud
answered Nov 19, 2015 by Arnaud C. (Audiokinetic) (200 points)
+1 vote
Tried to reproduce your setup with variable repeated calls to AkSoundEngine.SetRTPCValue() on Mac platform (using ElCapitan 10.11.1, WWise 2015.1.3, and Unity 5.1.2.f1) and I couldn't get more that 100MB of transient memory usage during execution. I then upgraded to Unity 5.2.3.f1 and then indeed, more than 1GB of transient memory usage while running the same scene. I then tried an empty Unity project without using Wwise integration at all (single cylinder) and the process was also using more than 1GB or transient memory whereas it only uses 60MB when generated with Unity 5.1.2.f1.

Did not see any noticeable mention about this here http://unity3d.com/unity/whats-new/unity-5.2

Here's some screen grab from both versions

http://ge.tt/7BxaeCS2

Arnaud
answered Nov 20, 2015 by Arnaud C. (Audiokinetic) (200 points)
When looking into this further I agree that the memory seems to jump up on OS X even without any RTPC function calls. The reason why I'm investigating RTPC function calls is because it seems like there is a memory leak in a different much bigger project I am working on. I am and was using strings when calling the RTPC functions. There is still the question of why OS X uses so much more memory than Windows but perhaps that's a bug with Unity. Below is a link to a zip of the test project I used if you would still like to look at that.

WWise Test Project: survivethedistance.com/wwisebugs/WWise%20Test%20Project.zip

I'm really having a hard time narrowing down what is causing the memory leak in my other project. If I call RTPC functions a bunch the memory will continue to go up and crash the application on OS X, however, Windows and Linux are fine. It's a strange bug but I'm having a hard time reproducing it in smaller test projects. Anyways, thanks for the help and thanks for looking into this!
...