I think I am leaking! :)
I think I am leaking! :)
- Subject: I think I am leaking! :)
- From: "Steven W. Riggins" <email@hidden>
- Date: Sat, 27 Oct 2001 01:48:59 -0700
Hi Folks,
After 2 days of archive searching, doc reading, emailing friends, I am confused. My first real Cocoa app appears to be leaking memory from NSHTTPURLHandles created by NSURL. Here is a method I wrote:
- (void)leakTest
{
NSURL *lURL;
NSData *lData;
int count;
int loop;
for (loop = 0; loop <= 50; loop++)
{
lURL = [[NSURL alloc] initWithString:[[self mSettings] mURL]];
if (!lURL)
goto releaseMem;
lData = [lURL resourceDataUsingCache:NO];
if (!lData)
goto releaseMem;
releaseMem:
[lURL release]; // no longer needed
}
return;
}
I call this from windowDidLoad in my NSWindowController subclass.
When looking at my app with ObjectAlloc, I see 51 NSHTTPURLHandles. Looking in the instance browser tab, I see two events per instance, an AllocationEvent and an ObjectAutoreleasedEvent, but no release/dealloc.
This is boiled down from my larger issues, but trying to find out how I should be releasing the data from the NSURL has become an obsession :)
Thanks!
Steve
P.S. 2 all niters, I am running out of Code Red, so the help is appreciated, lol