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
2
Question by JustinRyder · Oct 05, 2012 at 08:03 PM · instantiateassetsloadresourcesunload

Resources.Load() Asset Management

I understand that Resources.Load() will get the asset at the specified path from the Resources folder. What I can't quite figure out from the documentation is the effect of calling this multiple times. Calling Resources.UnloadUnusedAssets() or Resources.UnloadAsset() can free up the memory used from loading an asset.

MyPrefab is not loaded into memory, it is only stored in the executable file

     GameObject gameObj1 = Instantiate(Resources.Load("MyPrefab")) as GameObject;
 

Resources.Load() loads MyPrefab into memory as an asset that can be used. Instantiate() instantiats the Resources owned MyPrefab from memory. There are now 3 copies of MyPrefab: 1. On disk (stored in the executable) - the prefab template. 2. In memory (stored in Resources) - the prefab template, but ready to be used. 3. In memory (as an instance in the scene) - gameObj1, an independent copy of the Resources asset.

     GameObject gameObj2 = Instantiate(Resources.Load("MyPrefab")) as GameObject;
 

Resources.Load() is called again on the same path. Are there now two Resources owned instances of the MyPrefab template in memory? Or does Unity realize that the asset has already been loaded, and just send me a copy of it to instantiate? If this is the case, what is the overhead like for Unity to determine that loading the asset is useless? Does it load it, then realize there are two copies and destroy one?

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 ThePunisher · Jan 13, 2013 at 10:45 PM 0
Share

I'd highly doubt that they would load it then check if had already been loaded. Just saying that made me sick :(.

I was looking for confirmation that subsequent calls to load an asset simply return the reference to the already loaded asset. But now I can't find where it said that. I hope it wasn't in the release notes of the recent versions but I'll check and come back when I have your answer.

avatar image ThePunisher · Jan 13, 2013 at 10:57 PM 0
Share

Hmm, went through the release notes but I couldn't find anything on it. I did find this post, although I can't be 100% sure since it isn't a Unity developer saying it.

http://forum.unity3d.com/threads/98854-Resources.Load-used-multiple-times-on-same-resources-take-more-memory

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

11 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

Related Questions

I think I abuse of Ressources.load 2 Answers

How does resource loading and instantiating consume memory 0 Answers

resources.load (instantiate from this.transform) rather then the centre of the map? 1 Answer

Instantiate button prefab problem 0 Answers

How to Load/Unload assets in Editor? 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