iPhone vs. iPod Touch

Member
Posts: 241
Joined: 2008.07
Post: #1
I'm thinking about buying an iPhone to assist with development. I know there's a simulator and it works to a certain extent but I would feel more confident seeing my app on the actual device.

I'm wondering, does the iPhone simulator restrict memory and processing usage as it actually is limited on the phone? I would think so but does anyone know for sure?

Now, the iPhone has GPS and a few other neat features that the iPod Touch doesn't have, not to mention calling. I just don't have $100.00 a month right now to keep an iPhone active. What I want to ask is, does the iPod Touch have the same capabilities as the iPhone, as far as development of a graphics based OpenGL application goes? I mean, if I got an iPod Touch, would it suffice for iPhone testing?

Thanks!!
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
Yes, iPod Touch works great for iPhone development.

The simulator is not the same as the device, in many ways, but especially in terms of performance. The OpenGL performance you see in the simulator, in particular, can be wildly different than what you see on an actual device.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #3
Thank you Jake.

I get the impression that the iPod Touch is actually more powerful than the iPhone. Can anyone confirm or deny this?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
I only have a Touch so I can't say for sure, but everything I've read indicates that if there is any difference in performance between the touch/iphone/2g/3g, it isn't enough to really notice.
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #5
the iPod touch should be fine, but one gotcha to test for is that on actual customer iPhones and iPods you can have less memory than you expected if they have been running other apps that haven't given up their memory yet. (Guess who got caught by that one).

It's not as visible in the docs as possibly it should be (it should be on the first page and it giant type) but have a look for the memory warning notification stuff and implement it.

When you're testing on your iPod, try your game straight after you've run the music player and safari with a few pages open and see if it survives Wink

Switching the iPod off and on again clears the memory back to normal.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #6
Thank you. Smile
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #7
Hey Zwilnik, how much memory do you suppose we can count on to be there when we run? I mean, I can't really free up any resources and still play the game. I need like 15 to 20 MB and if it isn't available then the user is SOL, I guess. Right? Or is there something I'm missing?
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #8
It's extremely variable depending on what's been running. Reports vary from the field though, but generally Apple seems to recommend only having stuff in memory that you need at the time.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #9
Doesn't OpenGL have a way to tell you how much graphics memory is available?
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #10
I found this, you may find it informative:

Speculating on the iPhone memory footprint and CPU speed.
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #11
I find that the iPod Touch runs slightly faster then the iPhones, I suspect this is due to a lot more background processes running on the iPhone.

As far as memory I have gotten low memory warnings at just around 10 MBs, Try to keep it under 14 or you may find yourself in trouble.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #12
Thanks for that info Kodex. Wow, and here I was rolling along thinking there was plenty more room than that...
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #13
bmantzey Wrote:Doesn't OpenGL have a way to tell you how much graphics memory is available?

No. This is OS-specific.

And what does it mean, if the graphics memory is virtualized across all currently running processes?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #14
arekkusu Wrote:No. This is OS-specific.

And what does it mean, if the graphics memory is virtualized across all currently running processes?

This brings up a couple questions:

1) What would you recommend we do to calculate how much video memory we're using up?

Should we actually add up all the data we're giving to OpenGL? e.g. I glTexImage2D a 512 x 512 GL_RGBA using GL_UNSIGNED_BYTE, so that should calc out to 1 MB right?

2) I don't understand how the memory is "virtualized across all currently running processes". When I look at my app's "Real Memory" stat in Activity Monitor in Instruments, while running it on the device, is part of that memory footprint made up of OpenGL managed memory, or is there some other reserved place in system RAM? And if it's in application RAM, does that count toward what the system uses to decide when to send a memory warning? I assume it would...
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #15
Hostinfo does indeed return 11x MB. However, you can malloc about 730MB of data before things start getting real screwy, and malloc finally fails even when you try and malloc 1KB. This at least gives you some insight on what you have to work with memory-wise. I'm not quite sure on what will give you a memory warning, because this doesn't. I did see someone create an NSArray with about 30 screen-sized images((320 * 480 * 4 + extra junk) * 30 == 17MBish, two copies, 34MB briefly), and make a quick copy of it before it was autoreleased, and he was getting thrown a memory warning. However, without any handling of that memory warning, his application was not shut down. The autorelease was called in time on the extra copy, it would seem.

Here is the code to test yourself. Just create a window-based application and substitute the implementation block with the following implementation block. You can run Instruments on it to see the allocations taking place. If you try and run Leaks in Instruments... it will still run on your device, Instruments will think it's running, Xcode will think it crashed. And then Instruments hangs and your device freezes until you hold both buttons down for awhile, so I suggest not using it. Also, run this on the device and not on the simulator, otherwise you will get bad results(Hostinfo returns 2GB for the simulator).

The results are the same for the first-gen iPhone and the iPod Touch. I don't have a 3G to test.

Code:
//
//  MemoryTestAppDelegate.m
//  MemoryTest
//
//  Created by Joe Conway on 10/22/08.
//  Copyright Big Nerd Ranch 2008. All rights reserved.
//

#import "MemoryTestAppDelegate.h"

@implementation MemoryTestAppDelegate

@synthesize window;

    
- (void)applicationDidFinishLaunching:(UIApplication *)application
{    
    UILabel* label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 225, 320, 30)] autorelease];
    [label setTextAlignment:UITextAlignmentCenter];
    [label setText:@"RAM"];
    UILabel* label1 = [[[UILabel alloc] initWithFrame:CGRectMake(0, 263, 320, 30)] autorelease];
    [label1 setTextAlignment:UITextAlignmentCenter];
    [label1 setText:@"Allocating 1024 KBs"];
    
    [NSTimer scheduledTimerWithTimeInterval:.01
                                     target:self
                                   selector:@selector(wasteMemory)
                                   userInfo:nil
                                    repeats:YES];
    [window addSubview:label];
    [window addSubview:label1];
    [window makeKeyAndVisible];
}
- (void)wasteMemory
{
    static int kbsPerAllocate = 1024;
    static float amtAllocated = 0.0;
    if(kbsPerAllocate > 0)
    {
        void* amt = malloc(1024 * kbsPerAllocate);
        if(!amt)
        {
            kbsPerAllocate /= 2;
            [[[window subviews] objectAtIndex:1] setText:
                [NSString stringWithFormat:@"Allocating %d KBs", kbsPerAllocate]];
        }
        else
        {
            amtAllocated += (float)kbsPerAllocate / 1024.0;
            //Don't do this to get a pointer to the label UI element.
            //I didn't want you to have to add anything to the .h file.                
            [[[window subviews] objectAtIndex:0] setText:
                [NSString stringWithFormat:@"%f MB", amtAllocated]];
        }
    }
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication*)app
{
    NSLog(@"MEM WARNING!");
}
- (void)dealloc {
    [window release];
    [super dealloc];
}


@end
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How much can I stuff in to video ram? (on iPhone/iPod touch) Jamie W 9 10,364 Aug 6, 2010 05:23 AM
Last Post: mariocaprino
  Pause/Resume on IPod touch tonysameh 0 2,438 Jul 26, 2010 06:34 AM
Last Post: tonysameh
  iPod Touch not multitasking not working??? Toontingy 1 4,070 Jun 24, 2010 04:13 PM
Last Post: sealfin
  iPhone Only? Not for iPod Touch? daveh84 4 4,312 May 7, 2010 10:46 PM
Last Post: cmiller
  Detecting hardware, which iPhone/iPod I'm running on? Jamie W 9 7,721 Apr 13, 2010 11:27 AM
Last Post: Frank C.