Memory allocation

0 views
Skip to first unread message

biker

unread,
Nov 13, 2009, 12:13:11 AM11/13/09
to iPhone Application Development Auditors
Hello All,

I have question regarding
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[pool drain];
What is the significance of this allocation of memory?

When I run the following code without above 2 lines of code it always
gives me an error of -"just memory leak".
NSString *path = @"filename.wav" ;
const char *infilename = [path UTF8String] ;

Help Please!!!

Thanks



Sukima

unread,
Nov 14, 2009, 12:19:18 AM11/14/09
to iPhone Application Development Auditors
Wow no one took this one yet?

The auto release pool is the work horse behind the autorelease
keyword. Without it your just leaking memory everywhere.

When you use [someObject autorelease] your telling the it to add a
reference to the auto release pool. You use this to relinquish
ownership of an object to a calling method. All the objects that Apple
has (Foundation, UIKit, etc.) all use this. Without those two lines
there is no auto release pool to work with.

I would go back to the first or second lecture about memory
management. There is a lot more detail about this there.
Reply all
Reply to author
Forward
0 new messages