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
1
Question by Ludovic · Jan 17, 2011 at 06:22 PM · optimizationassetbundlememory

Releasing assets loaded from asset bundle

When I tried to destroy an Object loaded from an asset bundle, I get this error message :

"Destroying assets is not permitted to avoid data loss."

If I used DestroyImmediate( obj, true ), Unity crashes.

The code is basically :

Texture2D texture = assetBundle.Load( "textureName" );
assetBundle.Unload( false );
Object.Destroy( texture );

In my project, it would allow me to load assets dynamically and destroy them when I don't need them anymore. In my understanding, the loaded texture is not an asset, it's a bunch of bytes uncompressed from an asset. So I should able to release them to free up memory.

I know there is the AssetBundle.Unload( true ) method, but I need the asset bundle in memory and AFAIK, the whole content of the asset bundle is kept in memory.

Is there a way to get this work ?

Comment
Add comment · Show 1
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 mrai · Feb 28, 2012 at 01:38 AM 0
Share

hey @Ludovic, did this bug get solved for you? Could you please send me a link to the bug report you created?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by jonas-echterhoff · Jan 17, 2011 at 07:55 PM

DestroyImmediate should in theory do what you want. It certainly should not crash. Can you submit a bug report so we can take a look?

Edit: I had a look at the bug report. Crashing here is a bug and we'll have it fixed. But, to actually solve your problem at hand, what you should do is just to lose all references to the Texture, and then call Resources.UnloadUnusedAssets().

Comment
Add comment · Show 4 · 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 Ludovic · Jan 18, 2011 at 09:27 AM 0
Share

I just send a bug report about this problem.

avatar image Ludovic · Jan 21, 2011 at 09:09 AM 0
Share

Edit : I'll try that. Thanks for the tip

avatar image theschwartz · Mar 29, 2012 at 06:41 AM 1
Share

Has this been solved? I have the same problem. The standalone player crashes when I try to destroy the assets loaded from an asset bundle after I unloaded the asset bundle using Unload(false). Please help!!

avatar image jasonFHH · May 31, 2012 at 03:20 AM 0
Share

Would love to know the answer to this. I've been looking for answers to similar questions ( http://answers.unity3d.com/questions/258445/why-does-unity-crash-when-i-stop-playing-an-asset.html?sort=oldest ) . I tried yielding while waiting for the next frame to load. This got my scene to show up, but it crashes the editor the second I hit "unpause" — I assume this is due to the Play button in the Editor automatically calling DestroyImmediately on the objects? It has been too problematic to work with and I haven't gotten any definitive answers from anyone yet, so unfortunately my $$anonymous$$m will have to pass on asset bundle loaded scenes as we cannot even test our game in the Editor. :( :( :(

Has anyone else figured out how to do this????

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Webplayer crashes on Chrome, but not on any other browser. Any way to avoid ? 1 Answer

How StreamedSceneAssetBundle differ from AssetBundle in terms of scripting? 0 Answers

Keeping assetbundles in memory vs always loading from cache 1 Answer

How to have 2 sets of textures and make sure only one is loaded? 0 Answers

Are Texture2Ds in a Resources folder always loaded in memory? 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