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 there,
I have two questions if I may:

1) I am making a 2d view from top racing game using OpenGL. And I want to put there really big background. Unfortunately it doesn't work on iPhone. So my question is how big texture I can use?

2) This one is related to the first one. Is there any way in Obj-C to determine the size of an object? And how much memory I have used?

Thanks. If you need more info, bit of code perhaps, just ask I can provide that.

Thank you again.
 

mlady

macrumors member
Original poster
Sep 18, 2008
31
0
I think I have figured out the first problem. It can be up to 1024x1024 pixels. So I can put together the background from these pieces.

But I am still interested how can I determine size in bytes of an object?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
There's no method that will allow you to determine the full memory footprint of an arbitrary object. You can use the sizeof operator to tell the size of the struct that an object represents. However, many objects will also have pointers to other blocks of memory. These are private and there's no language support to determine them. Also, various classes may have memory that's just separate from the individual instance. For instance all NSObjects have a retain count. Where is this stored? There's no instance variable that holds it. Also, various classes will preallocate memory for a cache so one api call may allocate a large block and another identical api call may allocate no memory.

What you can do is use the ObjectAlloc tool. It is possible to view all memory allocations done by your app with that tool. So it is conceivable that you could look at the memory allocations that occur when you create a given object or call a given OS API. You can view the total memory footprint of your app over time. This is probably the best you can do but it also has limitations.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.