Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-04-2009, 11:48 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Question Memory problem & Leaking ?!?!?

I know I asked this question before, but i am still very confused.
My app works perfect on the simulator, but on the iphone it crashes after a while (it's a multi-player game which keeps receiving data and doing stuff)
So i ran the Leaks performance tool, As the application goes I get more leaks.

I still don't understand what is a leak? When should i release objects and how?
What I'm currently doing is calling release on objects only when I created an instance of them through alloc

I have so many classes that inherit from NSObject, and i use alloc to create an instance of them. From what i know release calls the dealloc method in the object. So is it necessary to create a dealloc method for each class that i wrote? Do i need to dealloc the super class?
I tried something like this: [super dealloc]; on the class that I wrote which is being called when i'm done with the object, and that causes the whole application to crash even on the simulator.

I know so many questions I would appreciate any help or tips on this.
aryaxt is offline   Reply With Quote
Old 03-04-2009, 12:21 PM   #2 (permalink)
iPhone Development Traine
 
Join Date: Dec 2008
Location: Philadelphia, PA
Posts: 146
MattjDrake is on a distinguished road
Send a message via Skype™ to MattjDrake
Default

You may want to go back and make sure that your class is releasing objects in the dealloc method like so.



Here is a link to a complete article I wrote about using custom classes including a good way to handle memory:

Here is How you Use a Class in Objective-C | How to Make iPhone Apps

One more thing that helps is to use the "retainCount" function. Each object should have this so you can use this to test if your objects seem to be getting over or under released.

Here is how you can write the retain count to the log:

Code:
NSLog([NSString stringWithFormat:@"Retain Count:%i", [someObject retainCount]]);
Look up using "NSZombie" as well - I found that to be very helpful in dealing with memory problems.

One more thing: coming up with and following strict rules regarding memory management is a good idea. Good luck, this is a tough issue on the iPhone..
__________________
Click this to read my blog: How To Make iPhone Apps

Author of Objective-C Recipes, blogger and trainer
MattjDrake is offline   Reply With Quote
Old 03-04-2009, 05:05 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Default

Thanks a lot, this is a great help
and explains very well
aryaxt is offline   Reply With Quote
Reply

Bookmarks

Tags
leak, memory problem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 339
2 members and 337 guests
guusleijsten, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:44 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0