2d racing game - background(memory) problem!

Discussion in 'iOS Programming' started by mlady, Sep 24, 2008.

  1. mlady macrumors member

    Joined:
    Sep 18, 2008
    #1
    Hi,

    I am making 2d racing game. First I make big background in Photoshop then cut it to many pieces 1024x1024 px. Then I want to load it to my game (I am using the Texture2D class). Unfortunately I am not able to load it all, only several pieces - iPhone crashes at the beginning. I think it's too much memory for it?? I wonder how can it run big 3d games...

    Any ideas what I can do about this? Should I alloc/dealloc pieces I don't use? Or use completely different solution?

    Thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    The iPhone only has 128Mb RAM for everything: the OS, the application code and memory for running apps. How many 1024x1024 pieces are you trying to load. How big is each in Kb? Most 3D games are probably using much smaller textures...
     
  3. mlady thread starter macrumors member

    Joined:
    Sep 18, 2008
    #3
    Hi, thanks for quick reply.

    I tried about 10 pieces. 6 is the maximum. Each is about 40-80 kb big.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Well, on their own, that would not sound like too much. Try running the code in Instruments and see how much memory you are using/if you are leaking lots of memory somewhere.
     
  5. mlady thread starter macrumors member

    Joined:
    Sep 18, 2008
    #5
    Instruments? Haven't heard of that. Is it a Xcode tool? That is exactly a tool I needed. To see how much memory is my app consuming...

    Thanks.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Yes. It's available on the Run menu. Unfortunately I'm at work on a PC so can't give you more details. It's covered in the documentation/getting started videos...
     
  7. mlady thread starter macrumors member

    Joined:
    Sep 18, 2008
    #7
    Thanks, I tried it, it's a great tool. I didn't watch those 2 first videos...

    My Net Bytes are ok, about 40 MB; But Overall bytes over 150 MB(on the simulator, device crashes). I think this is because it uses lots of temp data storage in that Texture2D class while loadign images. Is it bad? Is it why it crashes?

    Or maybe even 40 MB of RAM is too much for iPhone?? How much is the maximum?

    Thanks
     
  8. mlady thread starter macrumors member

    Joined:
    Sep 18, 2008
    #8
    Ok I want to try one thing, I want to alloc/dealloc pieces of texture, but is there a way to determine if it was allocated?
     
  9. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #9
    Unfortunately I have no idea how much RAM a single process can use.

    If you call alloc and get a nil pointer back it failed...
     
  10. mlady thread starter macrumors member

    Joined:
    Sep 18, 2008
    #10
    I am now allocating those pieces of texture just when I need it, bud when I load it, it freezes for a while :(

    There must be some other way!

    Please help.
     
  11. kage207 macrumors 6502a

    Joined:
    Jul 23, 2008
    #11
    Have you tried running the program with the car on a blank background?
     
  12. newb16 macrumors regular

    Joined:
    Feb 27, 2008
    #12
    In jpg file? But I suppose they are stored uncompressed in memory when they are already loaded, and occupy some 1000*1000*(3..4) , depending on whether there is alpha channel, so 40 mb for all of them.
     

Share This Page