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 01-30-2009, 07:34 AM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 1
scoholl is on a distinguished road
Red face Memory Leak Causes Crash?

I'm a bit of a newbie to Objective-C, but I've managed to create a pretty cool game for my iPhone. It's working fine on the Mac, and when I move it to the device it works fine there... for awhile... but then it crashes after about ten minutes of play. I'm able to consistently reproduce the crash. I figure it's some kind of memory leak that's growing to the point where the device can't handle the app anymore (where as the Mac wouldn't be affected so quickly), but for the life of me I can't figure out where this leak may be happening. I've used the Instruments tool to run the app and I can literally see the leak as it happens over and over again, but after that I look at the Instruments tool and say, "Okay, now what?" Again, I'm a newbie (with 10 years of VB), so please don't crucify me for not knowing this, but can someone tell me how in the hell I'm supposed to read the information I receive from the Instruments app? It's a bunch of colored squares and points in memory, but nothing that states, "Okay, this was allocated here, but never released, so..."

Thanks for the help! Just a point in the right direction should be enough.
scoholl is offline   Reply With Quote
Old 01-30-2009, 09:34 AM   #2 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
RickMaddy will become famous soon enough
Default

Actually Instruments is showing you exactly what was allocated and where. Find the colored square representing your application (not code from the SDK). Double click on the last one that is in your own code. This should bring up the file and line in Xcode.
RickMaddy is offline   Reply With Quote
Old 01-30-2009, 11:57 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 188
jsonli is on a distinguished road
Default

Quote:
Originally Posted by RickMaddy View Post
Actually Instruments is showing you exactly what was allocated and where. Find the colored square representing your application (not code from the SDK). Double click on the last one that is in your own code. This should bring up the file and line in Xcode.
Good to know.
jsonli is offline   Reply With Quote
Old 01-30-2009, 02:35 PM   #4 (permalink)
Lost in a sea of code
 
BostonMerlin's Avatar
 
Join Date: Apr 2008
Location: Boston
Posts: 399
BostonMerlin is an unknown quantity at this point
Default

On the detail pane (right side in instruments) look for your file names in those colored boxes.. your leak may not be the last in the list but follow the chain from the bottom up until you find your culprit.

I'm a windows dev for the past twenty years or so.. instruments is different but provides everything you need to know.. you just have to know where to look.

Good luck..
John
__________________
----------------------------------------------------------------------
I love being a dad, flying airplanes and writing code.
----------------------------------------------------------------------
Follow me on Twitter: @BostonMerlin
Feed your brain on Twitter: @iPhoneDev101
----------------------------------------------------------------------
iPhone Apps:
BostonMerlin is offline   Reply With Quote
Old 01-30-2009, 04:01 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Is everything in the list that has self % as the left column a line where there is a memory leak? I mean if that is the case, then it thinks lines like

NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CalculatorTableCellView" owner:self options:nil];

Are memory leaks. But code like that is taken from books that all have the same code for using a special nib created for a custom Table Cell View.

Thanks

Mark
bytor99999 is offline   Reply With Quote
Old 07-09-2009, 08:34 AM   #6 (permalink)
New Member
 
svenito's Avatar
 
Join Date: Jul 2009
Posts: 13
svenito is on a distinguished road
Default

I'm getting leak reports on the same call. Trying to load a xib for a custom UITableViewCell and leak check reports a memory leak on the
Code:
[[NSBundle mainBundle] loadNibNamed: ....
line.

There's no leaks until the table is scrolled.

Can't figure out why though.
svenito is offline   Reply With Quote
Old 07-09-2009, 10:21 AM   #7 (permalink)
New Member
 
svenito's Avatar
 
Join Date: Jul 2009
Posts: 13
svenito is on a distinguished road
Default

Quote:
Originally Posted by svenito View Post
I'm getting leak reports on the same call. Trying to load a xib for a custom UITableViewCell and leak check reports a memory leak on the
Code:
[[NSBundle mainBundle] loadNibNamed: ....
line.

There's no leaks until the table is scrolled.

Can't figure out why though.
I figured it out. Stupidly I forgot to set the identifier of my UITableViewCell in the XIB. I set that and ensured that the identifier passed to the dequeue call matches and I am now leak free.
svenito is offline   Reply With Quote
Reply

Bookmarks

Tags
crash, device, instruments, leak, memory

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: 316
6 members and 310 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog, Objective Zero
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
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:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0