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 10-07-2010, 01:20 PM   #1 (permalink)
Yko
Registered Member
 
Join Date: Sep 2010
Posts: 26
Yko is on a distinguished road
Default [Help] Memory question

Hey guys!

I know there are several memory posts out there and a good link to Apple's doc but I am still confused.

Suppose we have this:

// .h file
NSMutableArray *aMutArray;

// .m file
inside -(id)init

if(!aMutArray) aMutArray = [[NSMutableArray alloc] init];

aMutArray gets used through the entire .m file inside methods, etc...

If I read previously, what I allocate, I need to dealloc. The question is where? At the end? (void)dealloc?

Thanks.
Yko is offline   Reply With Quote
Old 10-07-2010, 02:37 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

yep, in your dealloc method
smithdale87 is offline   Reply With Quote
Old 10-07-2010, 04:41 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 386
SoulRed12 is on a distinguished road
Default

Yes, in your dealloc method of whatever object owns the aMutArray, you should place [aMutArray release]; Remember to never call an object's dealloc method directly.
__________________
HEY! Was this post helpful?
If so, it would be MUCH appreciated if you'd just click on one of these apps:



MyD
Take 1 minute to set up your MyD and you'll always be able to prove you own your device!

Membrik
Test your memory by sliding tiles to match chains of increasing difficulty.

©2011 Dardom Productions | Like us on Facebook!
SoulRed12 is offline   Reply With Quote
Old 10-08-2010, 08:12 AM   #4 (permalink)
Yko
Registered Member
 
Join Date: Sep 2010
Posts: 26
Yko is on a distinguished road
Default

Thank you mucho guys!
Yko is offline   Reply With Quote
Reply

Bookmarks

Tags
memory alloc help, memory management

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: 342
8 members and 334 guests
headkaze, mistergreen2011, nobstudio, Objective Zero, rayjeong, revg, Sloshmonster, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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