Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by whydoidoit · Apr 29, 2013 at 08:49 PM · iosmemoryasset bundles

AudioManager memory usage on iOS when using Asset Bundles

So I appear to have suddenly got a huge amount of memory being used by AudioManager in my iOS game.

It's only occurring when I have the scene in an asset bundle.

All of the music for the scene is in the Resources folder (so it is included in the build) but is directly referenced in the scene.

The total size of the audio for this scene < 15MB.

Here you can see the effect:

alt text

This is loading it without being in an Asset Bundle

alt text

How can I get it to not use this memory?

screen shot 2013-04-29 at 21.40.52.png (37.1 kB)
screen shot 2013-04-29 at 21.45.21.png (37.4 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Apr 29, 2013 at 09:14 PM 0
Share

The music for this game is set to stream from disc. I'm guessing that isn't working in a strea$$anonymous$$g scene Asset Bundle.

avatar image whydoidoit · Apr 29, 2013 at 10:05 PM 0
Share

Changing the music to be Compressed in memory saved 40$$anonymous$$B

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by whydoidoit · May 01, 2013 at 06:54 AM

So it appears that including a stream from disk audio file in an Asset Bundle is a big memory hog. It looks like the whole track is loaded into memory uncompressed.

The answer is to compress music in memory and to avoid direct references in the scenes, rather load them from an individual track bundle when needed.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zergling103 · May 01, 2013 at 02:36 PM 0
Share

So, in other words, stream from disk doesn't work?

avatar image whydoidoit · May 01, 2013 at 03:16 PM 0
Share

Not in an asset bundle...

avatar image Zergling103 · May 01, 2013 at 04:32 PM 0
Share

Okay, but I'm not using AssetBundles with my streamed audio. I have a game object in the scene with the music files attached to audio sources. They're all set to stream from disk. There is no loading of asset bundles involved - the only funny business is that the object they're attached to is set to DontDestroyOnLoad(). We have four songs, compressed their combined sizes total to something under 75 $$anonymous$$B. Yet the Audio$$anonymous$$anager object shows to be using almost half a GB.

avatar image Zergling103 · May 01, 2013 at 04:34 PM 0
Share

After making the audio sources all Compressed in $$anonymous$$emory, the size of the audio manager became 45 $$anonymous$$B, audio clips taking up 75 $$anonymous$$B. (There are more audio files than just the songs.)

Though this isn't good enough. We expect to have a LOT of songs in our game. Surely they wouldn't have Stream from Disk as an option if it was, as it seems, completely useless.

avatar image whydoidoit · May 02, 2013 at 09:46 AM 0
Share

Well Stream from disc worked for me before the asset bundles (see my second picture above), but failed dismally afterwards.

avatar image
0

Answer by Sisso · Apr 29, 2013 at 09:09 PM

I dont know about asset bundles, but everything directly referenced by a scene is automatic load, do not matters if it is in Resources or not.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Apr 29, 2013 at 09:12 PM 0
Share

You normally use a Resources folder (in addition to the obvious) to ensure something is in the build (like shaders that are referenced in bundle's shaders fallbacks or used to create materials at runtime) - this would normally mean that it wasn't required in the asset bundle.

avatar image
0

Answer by ferretnt · May 26, 2013 at 10:22 PM

Thanks for posting this Mike - hugely helpful when I was debugging iOS audio usage this weekend.

It seems that even without AssetBundles, using Stream From Disc on iOS is dangerous with short clips. I have just verified (both with Unity's profiler and Xcode) that if you have lots of short clips (like dialog), and select to stream them in from disc, you then get a single disproportionately large alloc, which shows up in the Unity memory profiler under Assets/AudioManager.

I currently have dialog totalling around 8Mb in a scene, and if I set all of it to "Compressed in Memory", then I get a 5.4Mb AudioManager allocation, plus the size of the compressed dialog under Assets/AudioClip. If I set it to "Stream from disc", then I get a ~64kb alloc per audio sample (presumably some header), plus a 15Mb audioManager alloc. The resulting ~10Mb difference between the two builds can be easily measured using Instruments' Activity Monitor.

Alex

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Asset bundles using double memory! 1 Answer

Unity IOS recommended specs? Should I buy a faster machine? Or What machine are you running for Unity + IOS Pro? 1 Answer

mp3 files giving ios memory warning 0 Answers

some iOS devices took more memory about 200%!! 1 Answer

AssetBundle memory profiling 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges