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 09-08-2008, 11:05 PM   #1 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 6
antuanix is on a distinguished road
Smile Interface Builder and memory management

Has anybody had a positive experience with using IB for the interface along with a good memory management?

If I have an interface and implementation file for every view controller and view, and every ui element gets correctly initialized/released etc in code... do I have a chance to avoid memory leaks?

The app I'm developing has lots of diferent views and controllers and images that get loaded from the internet, and i just want to avoid as much as possible CGRect's and alike and place elements visually with IB, too much to ask?
antuanix is offline   Reply With Quote
Old 09-08-2008, 11:21 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 802
scottiphone is on a distinguished road
Default

It works fine. It can't stop leaks in your own code but loading/unloading views should be ok assuming you use the starting point code (init from nib, awake from nib, etc)

If you allow rotating your phone then you likely have to do some coding yourself for positioning subviews.
scottiphone is offline   Reply With Quote
Old 09-09-2008, 11:07 AM   #3 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 6
antuanix is on a distinguished road
Smile

Thank you very much, it has been very useful to me, using loadNibNamed: I can load an an array of all the objects inside the xib and choose which one to load, really helpful!!
Good bye to having to program UI elements by hand!

The point now is, if a xib file has very many objects inside, will creating the array consume as much memory as initializing all?
Do i create separated xib to avoid wasting memory loading UI elements I don't need now?

Thanks
antuanix is offline   Reply With Quote
Old 09-09-2008, 11:32 AM   #4 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

When a nib is loaded every object inside it is created, whether they are shown or not. This takes up memory and also time. Typically you'll have one xib per main view/view controller and then load each nib as needed. Sometimes you'll have more than one view/view controller if it makes sense. What the file's owner object is and does controls how things are broken down.
PhoneyDeveloper is offline   Reply With Quote
Old 11-03-2008, 09:57 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 80
ecume is on a distinguished road
Default

loading a viewcontroller's view is straightforward, but how do you unload one? I know you can wait for a memory warning and let it happen automatically, but what if I want to programatically unload it ahead of time?

Last edited by ecume; 11-03-2008 at 10:03 PM.
ecume is offline   Reply With Quote
Old 12-08-2008, 10:00 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2008
Location: Columbus, OH
Posts: 57
pinpoint is on a distinguished road
Send a message via AIM to pinpoint
Default Deallocate running, but memory not freed

I have the same question.

I'm loading the view with a nib, and releasing the view controller after pushing it on the navigation stack.

I do see the view controller deallocating when it is popped from the navigation stack, however the memory in object allocations doesn't change. Do I need to unload the objects in the nib somehow?
__________________
Dave Peat
Pinpoint Solutions, Inc.
pinpoint is offline   Reply With Quote
Old 12-08-2008, 10:51 AM   #7 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

I haven't tried this but I think you can tell a view controller to unload its view as simply as

Code:
myViewController.view = nil;
One issue regarding viewcontrollers and nibs that's important is that Outlets need to be released in dealloc, and probably also in response to a memory warning.
PhoneyDeveloper is offline   Reply With Quote
Reply

Bookmarks

Tags
interface builder, 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: 328
13 members and 315 guests
akacaj, alexP, ClerurcifeDer, Duncan C, givensur, GraffitiCircus, guusleijsten, JmayLive, NetGuru, Paul Slocum, Punkjumper, Sloshmonster, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
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 09:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0