- Home /
Question by
deprofundiis · Mar 12, 2015 at 04:52 PM ·
materialprogrammingmemoryrealtimeleak
Memory leak when changing material
Was having a weird memory leak that I could no pinpoint. After frying some neurons I found that when doing this:
object.GetComponentInChildren(SpriteRenderer).material = object.GetComponent(Objects).object.normalMaterial;
unity simply adds another material to memory. Moreover, I would expect that some GC action would happen in the long run but no...
Anyone care to explain how to bypass this when I need to change materials in realtime without unnecessarily increasing memory usage?
Thanks
Comment
Try looking at this: http://answers.unity3d.com/questions/548420/material-memory-leak.html
Thanks a million! That really made me understand how it works.