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
0
Question by Orion 1 · Jun 28, 2010 at 10:10 AM · materialmemorydebugleak

Default-Diffuse material leak - how to find source?

Hello,

I have this highly convoluted project. Now recently I noticed, that when running it, it slowly gobbles up memory until finally either Unity or the game crashes from lack of memory.

So I used the DetectLeaks script and found out that the game creates like.. a few thousand materials per second. All called "Default-Diffuse (Instance)". I can "find" and destroy them, nothing in the game seems to change, but the memory problem is fixed, except for the performance hit of finding and destroying them in the first place.

But of course I'd rather be interested in finding out, where they come from. So, does anyone have an idea how I could find the object/script responsible for creating them?

And no, turning more and more parts of the game off will not work, as it is very entangled and one thing doesn't work without the other (hooray..). Please share your brilliant insights!

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 Orion 1 · Jun 28, 2010 at 01:35 PM 0
Share

Okay, I have a first lead. I'm changing the color of some materials from an animation. If I don't play that animation, nothing leaks.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Orion 1 · Jun 28, 2010 at 03:18 PM

Well. Through try and error I found the cause of the problem to be an animation, that fades the color of the material of an object. It seemed like in some cases the material could actually not be found from the animation (modified the subobjects).

Instead of using an animation, I now fade the material with an Enumerator, which works good enough.

Lesson learned: if I could start this project over, I'd use a lot less animations for mundane tasks.

Comment
Add comment · 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
0

Answer by Mike 3 · Jun 28, 2010 at 10:38 AM

First thing I would do is a project wide search for new Material(

After that it gets a little trickier, but you'll probably want to look for Instantiate, and see if any of them have materials as the object to instantiate

Not the most ideal methods I know, but I can't think of any easier ways

Comment
Add comment · Show 5 · 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 Orion 1 · Jun 28, 2010 at 11:26 AM 0
Share

Okay, well I'm not explicitly creating new $$anonymous$$aterials, so there goes the first one.

I have loads of Instantiate calls, but I only ever instantiate GameObjects and prefabs (also GameObjects).

I did hear that Unity sometimes creates materials just for giggles when you call renderer.material Which happens an awful lot. So often in fact, I have no idea how I could find out, which one could cause problems (or how to see THAT it causes problems).

avatar image Mike 3 · Jun 28, 2010 at 11:41 AM 0
Share

it only creates the new material the first time you call .material, and it cleans up after itself when you destroy the object

avatar image Orion 1 · Jun 28, 2010 at 12:40 PM 0
Share

Hm. That's off the list then (I suppose). Then there's something I heard that if I change properties on a material that it creates a new instance. Can that be right?

$$anonymous$$g. I do renderer.material.color = Color.Blue; And it turns it into an instance? I have a script that fades the color from black to white. So I'd have a new instance every frame?

avatar image Mike 3 · Jun 28, 2010 at 12:45 PM 0
Share

It does it once (It creates a new instance if material == shared$$anonymous$$aterial). I think your issue is elsewhere :(

avatar image Orion 1 · Jun 28, 2010 at 01:27 PM 0
Share

Do you know what this is all about? http://answers.unity3d.com/questions/10922/do-i-need-to-manually-destroy-material-model-instances-that-are-lazily-copied

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

No one has followed this question yet.

Related Questions

Memory leak when changing material 0 Answers

How can I track disassembly code back to a script? 0 Answers

Why is Unity taking up hdd space when I'm using it? 0 Answers

Same material, different textures - efficient or not? 1 Answer

Would setting this static cause a memory leak? 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