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 Evil-Dog · Oct 16, 2011 at 01:08 AM · memory

How to unload materials, textures and meshes from memory?

Hey there, I'm baffled at how hard it seems to handle memory correctly in Unity.

The type of game I'm working on had me separate different assets in different prefabs, sounds, sprites, animations, etc. which I instantiate and destroy once I'm done using them. I'm fine with the performance of all the instantiation and I call GC.Collect every now and then.

The problem I'm facing is that the memory used goes up and never goes down. I've been tracking the problem and the number of textures, materials and meshes in memory just keep growing, never being released from memory. I end up in a situation where, gradually, it's like I had loaded every resources in the first place. And of course it crashes before that.

Anyone has experience with unloading materials, textures and meshes out of memory once they're not used anymore?

Comment
Add comment · Show 10
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 syclamoth · Oct 16, 2011 at 01:38 AM 1
Share

Whoops! $$anonymous$$anaged languages. You have to wait for the monster of the deep to decide that you're no longer using the objects in question... I think there's a way to enable manual memory management, but I'm not sure if Unity allows you to do that...

avatar image Evil-Dog · Oct 16, 2011 at 02:18 AM 0
Share

Yeah the problem is that the monster of the deep does his GC correctly every now and then....but from what I read, materials, textures, meshes are not GCed because unity still keep references to them. So say I make my character eat an apple, so I load a few prefabs for apple sounds, apple graphics, apple animations, etc. The texture and material with the apple stuff is loaded...the apple animation ends, I destroy all these prefabs...good? no...the apple material and texture are sitll in memory. I make my character play with a doll, ah...material and texture for doll loaded...never unloaded, etc until the app crashes out of memory. I've read about Resources.UnloadUnusedAssets but that didn't help and was slow as hell. I'm at a loss and would really love some support to get those assets out of memory when I don't need them.

avatar image syclamoth · Oct 16, 2011 at 03:00 AM 0
Share

I thought UnloadUnusedAssets could be used as an AsyncOperation, meaning you can just fire it off and get on with the rest of your life? Unless, as you say, it just doesn't work the way you need it to...

avatar image Evil-Dog · Oct 16, 2011 at 03:02 AM 0
Share

Well it sure would be nice to make it async if it did free up the assets when I use it but it doesn't. I'm sure it does in the right circumstances. But I have no idea what those circumstances are. All I know is that this is way more complicated than it should be. Unused assets, please leave my memory alone :D

avatar image syclamoth · Oct 16, 2011 at 03:04 AM 0
Share

Ooh, Resources.UnloadUnusedAssets only works on the Resources folder! $$anonymous$$aybe you could use that? Except that the resources folder is usually exempt from the normal memory management...

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Profiler spikes 1 Answer

One texture loaded, used in multiple terrains, Possible? 0 Answers

texture memory question - colour tinting a single texture multiple times? 1 Answer

iphone variable values reset on application focus!? 2 Answers

Huge memory consumption even on windows 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