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

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

Draw This
($0.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-26-2009, 06:51 PM   #1 (permalink)
svveet
Registered Member
 
Join Date: Jun 2009
Location: Australia
Posts: 180
svveet is on a distinguished road
Default Memory Management / Releasing Objects

Im having problem with memory management problem, my app runs smoothly on the simulator, but it often crashes on my device.

I just want to know if there are some guidelines of when to release an object.

What i understand is
if something starts with alloc, you need to release it.
like
Code:
NSString *string = [[NSString alloc] init];
and if the object started with initxxxxx need to have autorelease
Code:
NSString *string = [[NSString initwithformat:@"123"] autorelease];
everything delcare in @synthesize, needs to be in - (void)dealloc.

I have declare an object inside a for loop, but when i tried to release it, it crashes.

What are the situation that we must release the object on?

Correct me if im wrong, thanks.

and what are the best way to code and to make sure keep everything in low memory?!

option 1:
Code:
NSString *string = [[NSString alloc] init];
self.stringIWant = string;
[release string];
option 2:
Code:
self.stringIWant = [[NSString alloc] init];

Last edited by svveet; 07-26-2009 at 06:56 PM.
svveet is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,014
Threads: 93,862
Posts: 401,918
Top Poster: BrianSlick (7,962)
Welcome to our newest member, Shimi574
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.