Hello Guest

Author Topic: Memory leaks on iOS  (Read 7062 times)

pixeltrap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Pixel Trap
Memory leaks on iOS
« on: June 26, 2014, 05:22:01 pm »
Hello,

We have an issue with the memory on iOS.

When we have tk2dSprites in our scene (around 2000), the memory on iOS keeps growing with around 1MB every 2 seconds, while moving through the scene. If you don't move, the memory is constant.

Again, if we disable all tk2dSprites, the memory is constant.

* the memory shown is taken from the Xcode Profiler (the real iOS memory reported by the OS).

Because of this we are facing a lot of memory warnings from the OS.

In our project we have around 170MB initially and it reaches 230MB and higher. Even 1GB devices (iPhone 5) get memory warnings because of this.

As a secondary thing, after reloading the scene (or loading another scene) the memory will be higher than the previous value.

Thank you!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory leaks on iOS
« Reply #1 on: June 26, 2014, 07:07:02 pm »
Check this out in the unity profiler. Memory usage shouldn't increase when moving through the scene, and the tk2d sprites dont allocate memory after they're created. You will need to track down were this memory is going.

pixeltrap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Pixel Trap
Re: Memory leaks on iOS
« Reply #2 on: June 27, 2014, 11:34:38 am »
That's the thing. In the Unity Profiler this increase is not shown.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory leaks on iOS
« Reply #3 on: June 27, 2014, 11:58:38 am »
You will have to submit a repro to Unity... This is out of our control.

pixeltrap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Pixel Trap
Re: Memory leaks on iOS
« Reply #4 on: June 27, 2014, 01:12:05 pm »
Ok..

It seems the increase is on all platforms. Even on Windows, in task manager the memory increases while moving, but not when staying fixed.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory leaks on iOS
« Reply #5 on: June 27, 2014, 01:27:50 pm »
If it doesnt show up in the profiler, its not happening in the .net runtime. We dont have any control of what happens engine side, and we dont allocate any memory or even have an update function (unless you have animated sprites). If its increasing constantly, its not from our code - you can pretty much disable the tk2d scripts on static sprites after they're created, they dont do anything until you tell them to change, eg. animated sprites, changing color, etc.

pixeltrap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Pixel Trap
Re: Memory leaks on iOS
« Reply #6 on: June 27, 2014, 05:00:51 pm »
Ok, so, I submitted a bug report to Unity, as you recommended.

Here's a video of the issue. I just modified the first scene in the tk2d sample: http://youtu.be/JrGY7BcvM10

To reproduce it just use this direct example: whoops, removed

You can run it on iOS or Windows. It seems to happen on all platforms.
« Last Edit: June 27, 2014, 08:30:30 pm by pixeltrap »

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: Memory leaks on iOS
« Reply #7 on: June 27, 2014, 06:27:44 pm »
You might to take down that example, it appears to be bundling TK2D with it

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: Memory leaks on iOS
« Reply #8 on: June 27, 2014, 06:36:06 pm »
You tried translating it, rather than just creating a new Vector3 each frame?

Like - http://pastebin.com/qEwreneX

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: Memory leaks on iOS
« Reply #9 on: June 27, 2014, 06:49:18 pm »
..also are you not batching the sprites? I got your sample from 700+ draw calls to 4 when grouping each row into a single sprite batcher. I don't have pro so I don't have the profiling tools, but the simple 'stats' tells me that the it's doing less.

pixeltrap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Pixel Trap
Re: Memory leaks on iOS
« Reply #10 on: June 30, 2014, 02:18:42 pm »
The batching only reduces the number of draw calls, but it doesn't fix the problem.

@unikronsoftware did you manage to take a look at the video posted?