How much memory usage is too much?
I'm starting to run into low memory issues, where my game app just exits with status 101, which I think is due to low memory.
I have the low memory warning delegate set up, but all it currently does is write to the log when it is called, so I at least know that it is happening. But I'm not sure how much memory usage the iphone should be able to handle before it calls that delegate. I think the largest chunks of memory usage I have are from graphics and sound, but I don't know for sure.
Instruments recently stopped working for the device, so I'm stuck with only using it with the simulator. According to Instruments, the game is hovering at just over 56,000,000 bytes of memory. That's about 55 mb. Is that high?
Actually, I have no idea why there is so much memory being used, because even my graphics usage is 16 mb of that (I currently have four 1024x1024 images in use, which comes to 4mb each if my math is correct), which leaves about 40 mb for sounds and object allocation? I currently barely have any sounds in the game at all.
If I look closer at the largest chunks of memory usage in Instruments, I see that it deals with chunks of memory that are exactly 4mb in size, and the responsible callers look like graphics functions. But I don't know why it appears to be holding onto more graphics memory than what it needs. 6 chunks of memory when I only have 4 different images.
By the way, my graphics are all loaded into OpenGL textures for 2D drawing.
I have the low memory warning delegate set up, but all it currently does is write to the log when it is called, so I at least know that it is happening. But I'm not sure how much memory usage the iphone should be able to handle before it calls that delegate. I think the largest chunks of memory usage I have are from graphics and sound, but I don't know for sure.
Instruments recently stopped working for the device, so I'm stuck with only using it with the simulator. According to Instruments, the game is hovering at just over 56,000,000 bytes of memory. That's about 55 mb. Is that high?
Actually, I have no idea why there is so much memory being used, because even my graphics usage is 16 mb of that (I currently have four 1024x1024 images in use, which comes to 4mb each if my math is correct), which leaves about 40 mb for sounds and object allocation? I currently barely have any sounds in the game at all.
If I look closer at the largest chunks of memory usage in Instruments, I see that it deals with chunks of memory that are exactly 4mb in size, and the responsible callers look like graphics functions. But I don't know why it appears to be holding onto more graphics memory than what it needs. 6 chunks of memory when I only have 4 different images.
By the way, my graphics are all loaded into OpenGL textures for 2D drawing.
According to Apple, you are limited to 24 MBs of memory.
Gillissie Wrote:I'm starting to run into low memory issues, where my game app just exits with status 101, which I think is due to low memory.
I have the low memory warning delegate set up, but all it currently does is write to the log when it is called, so I at least know that it is happening. But I'm not sure how much memory usage the iphone should be able to handle before it calls that delegate. I think the largest chunks of memory usage I have are from graphics and sound, but I don't know for sure.
Instruments recently stopped working for the device, so I'm stuck with only using it with the simulator. According to Instruments, the game is hovering at just over 56,000,000 bytes of memory. That's about 55 mb. Is that high?
Actually, I have no idea why there is so much memory being used, because even my graphics usage is 16 mb of that (I currently have four 1024x1024 images in use, which comes to 4mb each if my math is correct), which leaves about 40 mb for sounds and object allocation? I currently barely have any sounds in the game at all.
If I look closer at the largest chunks of memory usage in Instruments, I see that it deals with chunks of memory that are exactly 4mb in size, and the responsible callers look like graphics functions. But I don't know why it appears to be holding onto more graphics memory than what it needs. 6 chunks of memory when I only have 4 different images.
By the way, my graphics are all loaded into OpenGL textures for 2D drawing.
55 MB is too much. If you are using PNG textures, try to convert them to PVR.
Gillissie Wrote:I'm starting to run into low memory issues, where my game app just exits with status 101, which I think is due to low memory.
I have the low memory warning delegate set up, but all it currently does is write to the log when it is called, so I at least know that it is happening. But I'm not sure how much memory usage the iphone should be able to handle before it calls that delegate. I think the largest chunks of memory usage I have are from graphics and sound, but I don't know for sure.
Instruments recently stopped working for the device, so I'm stuck with only using it with the simulator. According to Instruments, the game is hovering at just over 56,000,000 bytes of memory. That's about 55 mb. Is that high?
Actually, I have no idea why there is so much memory being used, because even my graphics usage is 16 mb of that (I currently have four 1024x1024 images in use, which comes to 4mb each if my math is correct), which leaves about 40 mb for sounds and object allocation? I currently barely have any sounds in the game at all.
If I look closer at the largest chunks of memory usage in Instruments, I see that it deals with chunks of memory that are exactly 4mb in size, and the responsible callers look like graphics functions. But I don't know why it appears to be holding onto more graphics memory than what it needs. 6 chunks of memory when I only have 4 different images.
By the way, my graphics are all loaded into OpenGL textures for 2D drawing.
Your math is bit wrong. Each 1024x1024 pngs consumes 4 mb! thats 16mb for those 4 textures.
Its 1024 * 1024 * 4 bytes (every pixel is represented by RGBA) = 4 mb.
That's quite a lot. I can image you can't use PVR due to bad quality. I had the same problem. Don't forget that you will use additional things in game (many different sprites) which will consume even more memory!
I don't believe Instruments running on simulator, I think it shows weird data.
But from my experience I can tell you my app (link) which is pretty heavy in using graphics is not showing more that 50 mb in Instruments (on simulator). I can't run Instruments on real device (but what I remember it showed a LOT less.)
Also make sure you are loading textures using this method:
_textures[bckg] = [[Texture2D alloc] initWithImage: [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bckg1" ofType:@"png"]]];
My advice is use only 2 1024x1024 pngs. Memory is very sad thing on iPhone. We can just wait for the new device wiv doubled ram!!
Hope this helped
mlady Wrote:Your math is bit wrong. Each 1024x1024 pngs consumes 4 mb! thats 16mb for those 4 textures.
Its 1024 * 1024 * 4 bytes (every pixel is represented by RGBA) = 4 mb.
I'm not sure where you see that my math was wrong, since it is exactly the same as your math, but I have trimmed down two of my images to be 512 instead of 1024. It's still in progress, so I don't know how much room I'll need for graphics yet, so I was holding empty space by using 1024 even though I wasn't actually using all the space yet. Trimming those two images alone has helped tremendously.
Anything over 12MBs of usage is in the danger territory of crashing. Staying under 20 is pretty safe but expect to get complaints of crashing from a minority of your users.
This is interesting. I have 4 1024x1024 pngs+1 more smaller one and may objects on screen and I have never had an issue on the device. The vield games blog mentioned you could have something like 6 of these before memory swapping occurs. So even if you go high, it sounds like it should swap not crash...
Does the 1st gen iPhone have less memory than the other devices? I have had a couple of users complain of frequent crashes (out of a few thousand) both have 1st gen iPhones, I cant get access one to experiment unfortunately.
kodex Wrote:Anything over 12MBs of usage is in the danger territory of crashing. Staying under 20 is pretty safe but expect to get complaints of crashing from a minority of your users.
Zombie thread...
Due to the fact that I can't use Instruments with my device since the last OS update (never upgrade during development), I'm having to find out the memory usage of my app manually using:
Code:
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
if( kerr == KERN_SUCCESS )
{
return(info.resident_size);
}
else
{
return(-1);
}The values I'm getting out are a little confusing in light of the above thread. My app allegedly uses 35mb. 10mb of that is allocated before I perform any allocations of any sort (i.e. I test at the start of initWithCoder in my EAGLView).
I tested this out on GLSprite, and found the same thing: 10mb used up before the program even does anything.
This is fine - apparently cocoa is a bit bloated. However, how does this fit into my memory considerations now? People say 'use less than 12mb' - presumably that's discounting the Cocoa 10mb bloat?
Apologies if this has been discussed to death elsewhere.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| RAM usage | sealfin | 14 | 6,133 |
Oct 20, 2010 04:02 PM Last Post: Applewood |
|
| host_statistics memory usage output confusing | kendric | 0 | 3,313 |
Jan 11, 2010 02:50 AM Last Post: kendric |
|
| Memory Usage | haudio | 9 | 4,141 |
Jan 29, 2009 01:22 AM Last Post: haudio |
|
| Guideline for Memory Usage | aarku | 7 | 4,014 |
Dec 27, 2008 07:19 AM Last Post: jaguard |
|
| How do you determine memory usage? | green_ghost | 5 | 4,074 |
Sep 8, 2008 09:01 PM Last Post: green_ghost |
|

