Unknown audio samples take 1 GB

Here is my problem: I have a big scene with many audio sources, but actually a very small amount of audio clips. Most clips are set to “Stream from disk”, and others (very short ones) to “Compressed in memory”. However, Unity somehow takes up to 1 GB (!) with the audio subsystem. People with <= 2 GB RAM are complaining that they can’t play the game. The game itself, without counting the audio system, takes around 800 MB or less.

I attached screenshot from profiler.

How can it happen? I double checked all clips, compressed everything, but it’s still the same.

1767273--112028--audiomem.jpg

anyone?

Seems strange. Do you have Filters on any of those sources? Some filters can require a lot of RAM. You can also look into the build report to see more information about which assets take up space.

I have filters, but I think they’re supposed to show up as DSP/Reverb memory, and this memory is quite small, as you can see. As for build report - the build is just 400 MB and doesn’t seem to have anything excesful in it, the problem is in RAM.

Are any samples set to decompress in memory? Even a few accidentally could do it. Also, don’t take those memory numbers as gospel. If you’re unsure why things are happening, sometimes you just have to shut stuff down until you find the culprit.

No, nothing is set to decompress. I made an editor script which uses FindObjectsOfTypeAll to scan all audioclips, and there is really nothing set to decompress.

The problem is that the game takes 2 GB, it is consistent in both profiler and build, and 1 GB is this audio system. And people with small RAM can’t play the game, because it crashes with Out Of Memory errors.

:frowning:

Select the memory profiler, select “Detailed” from the dropdown menu and press “Take sample”. That should show you what’s taking the memory exactly.

This “Take sample” button is truly great! For some reason I didn’t even notice it before, it’s kind of small, haha. Now it really shows which samples take the memory.
But what is interesting is that all that huge audio samples are actually the ones set to “Stream from disk”, it’s music and ambient sounds mostly. Isn’t it supposed to… stream from disk, instead of being uncompressed (150 MB per track sometimes) in RAM all the time?
Here is an example I attached.

How long is that water sample, and can its quality be reduced a little? Definitely looks like a problem with the engine’s handling of audio flags, but reducing quality/increasing compression should at least alleviate it. The average person who doesn’t even have 2GB RAM probably doesn’t have a fancy audio system either :wink:

Audio set to streaming doesn’t stream from the editor currently. They said that’s coming in UT5. You’d have to profile a debug build to see it stream.

The water sample is around 10 minutes (not kidding), but it’s OK. If you look into older games like GTA 3, you’ll find similar 10-15 min ambient tracks for things like water (seriously). Things like that always worked fine, because audio libraries can do streaming. Seems like streaming is broken in Unity though.
I don’t want to reduce quality, I would rather make a proper native wrapper for some audio library. But fairly it’s not what I was expecting from using Unity :slight_smile:

Audio set to streaming doesn’t stream from the editor currently. They said that’s coming in UT5. >You’d have to profile a debug build to see it stream.
Oh, thanks, I’ll check the build

Yeah, 10 minutes isn’t much. I think 23MB is huge for that short a sample. I expect an hour :slight_smile:

An ambience sound shouldn’t be stereo, for example. Half the size off right there.