Author Topic: Memory Leak When Mix Two Atlases In One UIPanel  (Read 2059 times)

winddarklj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Memory Leak When Mix Two Atlases In One UIPanel
« on: June 12, 2014, 09:37:41 AM »


As in the graph, in Profiler(Editor mode),  after I remove all references and use UnloadUnusedAssets, there is still Wooden Atlas remained in Memory. I tested it, and found if I use one UIAtlas in one Panel,  the memory will all released; but if I use sprites from two UIAtlases, one of Atlases will not released. I know it is a bad practise using two UIAtlases in one UIPanel which matters with drawcall, but I wonder whether it is a bug?

winddarklj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Memory Leak When Mix Two Atlases In One UIPanel
« Reply #1 on: June 12, 2014, 10:38:13 PM »
I found the problem is not about two atlases, but UIFont, in memory, "Arimo20" GameObject is never released. I tested with one with UILabel, and one without it, and confirm that the only difference causing memory leak is whether I add UILabel

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Memory Leak When Mix Two Atlases In One UIPanel
« Reply #2 on: June 13, 2014, 04:35:36 AM »
Labels reference a font in order to print text. If you don't set the font to null, the label will obviously keep on referencing it. Do you ever set UILabel's bitmapFont to null?

winddarklj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Memory Leak When Mix Two Atlases In One UIPanel
« Reply #3 on: June 13, 2014, 05:50:52 AM »
Labels reference a font in order to print text. If you don't set the font to null, the label will obviously keep on referencing it. Do you ever set UILabel's bitmapFont to null?

Hi Aren, I have released UILabel for sure, only UIAtlas is still in the memory, I found the problem is actually NGUIText.bitmapFont is keeping referencing it. I'm using 3.6.3b.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Memory Leak When Mix Two Atlases In One UIPanel
« Reply #4 on: June 13, 2014, 06:02:52 AM »
Ah, so set NGUIText.bitmapFont to null before calling UnloadUnusedAssets.

winddarklj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Memory Leak When Mix Two Atlases In One UIPanel
« Reply #5 on: June 13, 2014, 10:58:57 PM »
Yep I have done it and then it works well. Thanks buddy.