Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 18, 2010, 09:44 PM   #1
BadWolf13
macrumors 6502
 
Join Date: Dec 2009
Multiple Windows and Memory Leakage

I've got an app with multiple windows that will often be opened for some time and then closed. So watching the memory usage of these windows and the window controllers is important to me. Here's the catch. I put an NSLog statement in the dealloc, which doesn't ever get printed in the console. I assumed that this meant that my window and window controller weren't being deallocated.

On the other hand, I just use the Leak Instrument on the app today. When I opened the second window, it shows 1 instance of my NSWindowController subclass, and when I close that window, it shows 0 instances of my NSWindowController subclass, and that no memory is being used by this class.

Don't these two observations contradict each other?
BadWolf13 is offline   0 Reply With Quote
Old Nov 18, 2010, 11:38 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
My guess is you're either reading Leaks wrong, or you have Garbage Collection enabled where finalize is called instead of dealloc.
kainjow is offline   0 Reply With Quote
Old Nov 19, 2010, 12:35 PM   #3
BadWolf13
Thread Starter
macrumors 6502
 
Join Date: Dec 2009
I'm using garbage collection. I just didn't realize that it called something else instead of dealloc. Should I override finalize to make sure that it releases its internal objects?
BadWolf13 is offline   0 Reply With Quote
Old Nov 19, 2010, 01:45 PM   #4
Comrade Yeti
macrumors newbie
 
Join Date: Nov 2010
No. Reread the garbage collection documents. The point of finalize is NOT to duplicate the dealloc method. You should only clean up NON GC'd resources in the finalize method as a last resort. Even then, finalize is not necessarily guaranteed to be called.
Comrade Yeti is offline   0 Reply With Quote
Old Nov 19, 2010, 01:53 PM   #5
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
Does the Leak Instrument even do anything under GC?
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Open Duplicate Window (xcode) Ipodize Mac Programming 3 May 16, 2011 09:47 PM
Installing 64 Bit Windows and other Questions Huntn Windows, Linux & Others on the Mac 10 Apr 25, 2011 10:32 AM
Need Help With Opening Multiple Windows and Running Script Neuhru Mac Programming 1 Jan 29, 2010 10:43 AM
Need Help With Opening Multiple Windows and Running Script Neuhru OS X 0 Jan 20, 2010 01:45 PM
Am I having memory leakage?? PB_deprived OS X 8 Jul 11, 2005 01:45 PM


All times are GMT -5. The time now is 10:56 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC