Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.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 11-30-2009, 03:17 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 5
Default Declaration\release coding problem, help needed.

Hi,
help needed to syntax a memory leak problem (state by the analyzer)
THX :-)

code:
@implementation APlayer

-(id)initWithFileNSString *)fName typeNSString *)fType
{

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:fName ofType:fType]];
self = [super initWithContentsOfURL:fileURL error:nil];
[fileURL release];

return self;
}

-(CFURLRef)soundFileURLNSString *)fURL
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
return CFBundleCopyResourceURL(mainBundle, CFStringCreateWithCString(NULL,[fURL UTF8String], kCFStringEncodingUTF8), CFSTR ("mp3"), NULL);
}

-(void) dealloc
{
[super dealloc];
}
@end
omri is offline   Reply With Quote
Old 11-30-2009, 03:21 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 519
Default

What did the analyzer show as not being released?
__________________
Water Your Body (ON SALE $0.99)

Top Paid in Health & Fitness!

Tic Tac Pro ($0.99)

New and Noteworthy!

Click here to see a really cool website
bravetarget is offline   Reply With Quote
Old 11-30-2009, 06:01 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 5
Default

leak 1:
1.Call to function 'CFStringCreateWithCString' returns a Core Foundation object with a +1 retain count (owning reference).

2.Object allocated on line 27 is no longer referenced after this point and has a retain count of +1 (object leaked).

leak 2:
1.Call to function 'CFBundleCopyResourceURL' returns a Core Foundation object with a +1 retain count (owning reference).

2.Object returned to caller as an owning reference (single retain count transferred to caller).

3.Object allocated on line 27 is returned from a method whose name ('soundFileURL:') does not contain 'copy' or otherwise starts with 'new' or 'alloc'. This violates the naming convention rules given in the Memory Management Guide for Cocoa (object leaked).

thx.
omri is offline   Reply With Quote
Old 12-01-2009, 11:31 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 5
Default

I used the foundation code instead.
omri is offline   Reply With Quote
Reply

Bookmarks

Tags
analyzer, coding, memory

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: 240
15 members and 225 guests
ADY, AragornSG, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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