• 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
Question by lukasz1500100900 · Aug 14, 2015 at 03:38 PM · unity 5assetbundlememoryunload

Unity 5 Asset bundle unloading problem

Hello, While I'm loading asset bundles without www.assetBundle.Unload(false); everything is ok on iPad Air 2, but on iPad with 1GB there is problem with memory(unexpected close), because I have big scene and a lot of assets. While I'm loading asset bundles with: www.assetBundle.Unload(false); Assets aren't loaded. What can I do? I created one asset bundle per one asset, because I need this in project.

Comment
NoseKills

People who like this

1 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 NoseKills · Sep 06, 2015 at 08:29 PM 0
Share

I've been wrestling with the similar problems lately. It really seems like putting scenes into asset bundles is not encouraged or at least has some downsides / unresolved problems, judging by the way the system works. Yet putting scenes into asset bundles would be the natural solution when your game is heavily scene/level based and you have over a hundred of them and need to add more.

Few of the issues I've encountered are:

1) assetBundle.LoadAsset("scene") returns null and just creates some kind of magical scene object into the application's scene list that can be loaded with Application.LoadLevel("scene") ONLY before you call assetBundle.Unload(); (just like the OP said). When dealing with other assets you can unload the bundle as long as you have a reference to the objects you want to instantiate later. This is not possible with scenes.

2) Scene asset bundles seem to take a lot of space when cached to disk. I admit this might be project specific but to me it seems astounding that in our project we can bundle up 150 scenes into 20 asset bundles (130Mb combined) to cut 30Mb off of the build size, but once those 20 bundles are cached to the device, the installation size goes up from 100 Mb to 2Gb (!!)

The cached size goes down considerably when you use less bundles as does the combined bundle size (makes you think there's some redundant info in the bundles), but because of issue 1), you can't use just a few huge bundles or you'll run out of memory when loading your scene from one.

3) AssetDataBase.LoadAssetAtPath() doesn't work with scenes so it's impossible to establish a transparent system where when working in the editor, you'd use the resources straight from AssetDataBase using `AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName() instead of bundles. This forces poeple to have the physical bundles whenever they work on the project and possibly commit these big binary files to version control, which is not cool.

4) I'm still investigating this but it seems loading scenes from bundles might be leaking memory. I do call www.Dispose() and assetBundle.Unload(false) after the level is loaded and they are not needed, and i do null the references to them so GC should take care of the rest, but If i load the same level over and over again, i still lose a considerable amount of memory with each loading.

avatar image NoseKills · Sep 06, 2015 at 09:55 PM 0
Share

Here's a good post about some of the problems. I read it way earlier but I didn't remember it mentions most of the problems I posted (and e.g. explains the bundle bloating) since i have run into those problems after i read it...

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

why UnloadUnusedAssets doesn't unload a asset? 0 Answers

Destroy single asset from AssetBundle 2 Answers

Addressable cache related issues facing 2 Answers

Loading Audio from Asset Bundles not working in Unity 5.2 2 Answers

Is it possible to Spawn an AssetBundle in HLAPI? 3 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