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 /
  • Help Room /
avatar image
0
Question by oliver-jones · Mar 16, 2016 at 10:13 PM · loadresourcesunloadunusedassets

Resource Unload - Doesn't clear memory fully

Hello,

I'm trying dynamically load and then unload a prefab at runtime via Resource Load/Unload. But every time I unload the prefab, I don't get all my memory back:

alt text

As you can see, at the start, the app is running normally. I then load in the prefab which then causes the large spike as expected, I then remove the prefab, but the memory doesn't go back down to the starting height. I only get about 25% of my memory back.

Why is this?

How I load:

 //get the prefab directory and load
 request = Resources.LoadAsync( "_SteamingPrefabs/" + GetPrefabName(story, page) );
 
 //visual UI
 while(request.isDone == false){
 
     var _f : float = request.progress * 100;
     progressWheel.SetPercentage( _f );
     yield;
 }
 
 //resource object itself
 loadedResource = request.asset;
 
 //make clone of prefab
 loadedPrefab = Instantiate(loadedResource) as GameObject;


How I unload:

 request = null;
 
 children = loadedPrefab.GetComponentsInChildren.<Transform>(true);
 for(var i = children.length-1; i >= 0; i--){
 
     UnityEngine.Object.Destroy(children[i].gameObject);
     children[i] = null;
 }
 children = null;
 UnityEngine.Object.Destroy(loadedPrefab);
 
 loadedResource = null;
 loadedPrefab = null;
 
 yield WaitForEndOfFrame();
 yield WaitForEndOfFrame();
 
 Debug.LogWarning("[SERIAL] Unloading Resources");
 yield Resources.UnloadUnusedAssets();
 
 yield WaitForEndOfFrame();
 Resources.UnloadUnusedAssets();

Is there something I'm missing here? I'm searching endless forums and threads, and I still don't know what I'm doing wrong??

Whats interesting, is that if I load the prefab back in - the memory goes back to the original height. Etc.

screen-shot-2016-03-16-at-220028.png (36.2 kB)
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

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.

Follow this Question

Answers Answers and Comments

51 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 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 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 avatar image avatar image avatar image

Related Questions

Resources.UnloadAssets doen't deallocate memory in build 0 Answers

Resources vs referanced prefabs 0 Answers

Load Object 3D From ImageTarget Prefab (Vuforia) 1 Answer

Resouces.Load returns null 1 Answer

Is it possable to exclude some objects from loading in the editor before building? 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