Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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...
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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...

Hi, thanks for quick reply.

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

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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.

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.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.

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...
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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...

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
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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...
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
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...

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.
 

newb16

macrumors regular
Feb 27, 2008
100
0
Hi, thanks for quick reply.

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

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.