Author Topic: NGUI material not being garbage-collected  (Read 6248 times)

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
NGUI material not being garbage-collected
« on: September 25, 2013, 07:06:09 AM »
Hi!

I'm struggling with this problem. I have a game with two scenes, menu and game. When jumping from menu to game the menu-atlas-material remains in memory. I can avoid this by disabling the ngui-root-gameobject before I load game but since I want my ngui loading screen to show while loading I don't want to do that.

I have also tried using DontDestroyOnLoad on the ngui-root-gameobject and then wait for OnLevelWasLoaded in game and then disabling and destroying the ngui-root-gameobject but the profiler still says I have references to menu-atlas-material from the fonts and atlas which I am sure are not used (since the whole thing works if I just disable the menu before loading game).

Got any ideas on how to solve this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI material not being garbage-collected
« Reply #1 on: September 25, 2013, 07:32:05 PM »
Which version of NGUI?

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: NGUI material not being garbage-collected
« Reply #2 on: September 30, 2013, 04:58:00 AM »
I was using 2.6.3 but now that I've updated to 2.7 the problem actually got worse. Now it doesn't even help disabling the ngui root.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: NGUI material not being garbage-collected
« Reply #3 on: September 30, 2013, 11:14:37 AM »
Upgraded to NGUI 3.0.1 but still the same result I'm afraid.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI material not being garbage-collected
« Reply #4 on: September 30, 2013, 11:22:49 AM »
Some pics of what you're seeing, as well as more info such as which device, how you are switching scenes, how you are unloading your atlas and when, etc can all help here. You are unloading the atlas, right? Because if you don't, then it won't just go away by itself.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: NGUI material not being garbage-collected
« Reply #5 on: October 01, 2013, 03:58:36 AM »
Since I'm loading a new scene with Application.LoadLevel, I don't use DontDestroyOnLoad and I can't find any static references it should be garbage collected shouldn't it? However the texture seems to remain in memory with a reference from the material which is referenced from the atlas prefab.

I have now put the texture and material in a resources folder and use Resources.UnloadAsset on both and that seems to solve the problem. Resources.UnloadUnusedAssets did not work I'm afraid. Also I tried debugging with geometry but there's none after jumping to the next scene.