Author Topic: Memory usage on mobile devices question  (Read 5454 times)

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Memory usage on mobile devices question
« on: October 20, 2013, 06:02:44 AM »
Hi,

I'm making an app for iOS and Android and i noticed that my memory is going up a bit too high for my taste (app is still running on iOS and Android but i'm over 200MB memory).
The thing is i'm reusing a background on every screen (for like 20 screens). This texture is a UITexture with a resolution of 2048x1536 @ 32bit. It takes up 9.0MB. Now let's say i have 20 panels each with this background, these panels are tweened in when user clicks a button on the screen. All panels are turned off (only the first screen). I thought that when a GameObject is turned off it wouldn't be loaded into the memory but that doesn't seem the case.
Here is a picture of the background i'm using:



The background is essential to the app so i can't reduce the quality, it must look crisp!
Any ideas to reduce the memory?

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Memory usage on mobile devices question
« Reply #1 on: October 20, 2013, 03:49:06 PM »
So i was brainstorming about this today, and maybe the answer is using Resources.Load on the background of the panel isn't on screen unload it. Any other sugestions?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Memory usage on mobile devices question
« Reply #2 on: October 20, 2013, 04:07:43 PM »
You can do that screen using a single 3x3 pixel texture.

1. Create a 3x3 white square in Photoshop.
2. Add it to your atlas and give it a 1 pixel border all around.
3. Create a sliced sprite using this texture. This will be the white background.
4. Create a thin vertical sliced sprite on the side and give it a red color. This is going to be your red line.
5. Create a thin horizontal sliced sprite and give it a light blue color. This will be your blue line.
6. Duplicate your blue sprite from #5 a bunch of times, positioning it as you see fit. You can use a UIGrid to do it automatically.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Memory usage on mobile devices question
« Reply #3 on: October 20, 2013, 04:37:39 PM »
that is actually a pretty good idea! Awesome :) i'm going to try that tomorrow.

Question2 how would you do the same with the screen below?:


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Memory usage on mobile devices question
« Reply #4 on: October 20, 2013, 06:12:19 PM »
Same exact way, except you will be adding more lines, and the hole looking sprites as well.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Memory usage on mobile devices question
« Reply #5 on: October 21, 2013, 08:02:32 AM »
Great this worked very good! Gone from 240MB memory to 160MB memory :) any other ideas to lower the memory?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Memory usage on mobile devices question
« Reply #6 on: October 21, 2013, 11:34:27 AM »
Use less big textures. :D