Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 riasat2274 · Mar 19, 2016 at 05:18 PM · audiomemory-leakresource.load

When the scene is changed once loaded the audio clip do not leave the memory. The total audio memory do not change. How can the memory be freed?

Hello, I was making a audio Controller to control and play audio clips using the controller. Audio controller is an indestructible game object, starting at the splash. It consists of the audio source which plays the clips needed. The Play function is with the audio controller. But the clips itself shall be with the individual scene with individual managers to manage the audio clips. Managers are the gameobject which consists of the reference to the clips remaining only in the scene. Now to the problem.

Problem 1: When scene 1 is loads so loads the clips in the memory. When scene 2 loads the total number of clips and the total audio memory accumulates. Even when returned to scene 1 the total audio memory and number of clips remain same for the rest of the game. Shouldn't the memory be freed of the previous clips when the new scene was loaded and the old scene destroyed(Using Unity.SceneManagement). Individual clips are referenced with individual scene in a game object as manager(scene2Manager as game object).

Problem 2: I tried Resources.UnloadAsset(audio.clip) on the managers in the OnDestroy() to run it at the end of the scene. It does work but with a more critical problem. About 2mb of residue(memory-leak) is left in the total audio memory found in the audio profiler. lets, sceme 1 total memory=10mb clip number=10. transition to scene 2 total memory=20mb clip number=10. Transition back to scene 1 total memory=12mb clip number=10. again transition to scene 2 total memory=22mb clip number=20. And this residue does not clear even when the unity editor is restarted. the computer has to be restarted to clear this residue.It accumulates over each scene transition.

Thank you for your patience. I hope i was able to make you understand the problem. I am working on android build of the unity. version 5.3.3f1.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by meat5000 · Mar 19, 2016 at 05:17 PM

How about UnloadAudioData ?

http://docs.unity3d.com/ScriptReference/AudioClip.html

Comment
Add comment · Show 3 · 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 riasat2274 · Mar 20, 2016 at 03:54 AM 0
Share

UnloadAudioData does not work. returns error message. Currently only clips that are not pre-loaded can be unloaded via UnloadAudioData(). UnityEngine.AudioClip:UnloadAudioData()

avatar image riasat2274 riasat2274 · Mar 20, 2016 at 03:57 AM 0
Share

Also UnloadUnusedAssets do not work, returns similar error message.

avatar image riasat2274 · Mar 20, 2016 at 04:24 PM 0
Share

I was able to solve the problem 1 using UnloadAudioData in OnDestroy function of the script. But the Preload Audio Data on the audio clips need to be unticked. Then the UnloadAudioData shall work. The clips have to be unloaded manually, but loads when the .Play() function is called. see Pre Load Audio Data... http://docs.unity3d.com/$$anonymous$$anual/class-AudioClip.html

crowd.clip.UnloadAudioData()

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Error Executing GetAudioManager.GetFmodSystem() Not enough memory or resources 0 Answers

Procedural Mesh, ToArray, and MemoryLeaks 1 Answer

Using input.getbuttondown to play audio = NOT WORKING? :( 2 Answers

Unity Editor Memory Leak 4 Answers

Song Allowments 1 Answer


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