views:

4598

answers:

14

Hi, i'm only create an project with a Utility Application template. This template has a native memory leak when i push "info button" to flip the view.

Anyone know how can i fix this leak ??? I just make an new project from this template, i don't add new objects.

A: 

In the current SDK utility template is no leak. How did you get the impression there's a leak in the template? It's just allocating memory which is needed for the views.

A leak is memory to which no pointers exist and which cannot be freed any more.

Nikolai Ruhe
Hi, i'm create a new project from Utility Application template, and run it with Instruments, and this show-me two leaks.I'm get:Leaked Object: Malloc 128 bytesSize: 128 bytesResponsible Library: CoreGraphicsResponsible Frame: open_handle_to_dylib_path
+13  A: 

That might be a leak or it might not be a leak. If you were to add the backtrace of the allocation, that would be helpful.

More likely than not, it isn't a leak, but some bookkeeping information that is being stashed away by dyld that leaks/Instruments loses track of.

Given that it is 128 bytes and I'm guessing there is only one of them, I would encourage you to file a bug via http://bugreport.apple.com and then forget about it for now as, in the unlikely case that it really is a leak, you will be equally as unlikely to be able to fix it from within your application.

bbum
Thanks for answer !
+5  A: 

Got the leak doing this:

XCode 3.2--

File, New Project, Navigation-based Application
Give it a name
Build It
Run With Performance Tools -> Leaks

When Instruments comes up, click on Leaks (you might have to click the little icon at the bottom that looks like four boxes within a box)

About 7 seconds after running you should see the leak: -- Malloc 128 Bytes, some Address, 128 Bytes, CoreGraphics, open_handle_to_dylib_path

I traced it to this code in the AppDelegate:

//APPLE CODE
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}

I broke out the navigationController (did a separate alloc and release) and COMMENTED OUT the addSubview: action - there was no leak - and, obviously, the screen was blank.

It wasn't until I attempted addSubview that the leak occurred. Since there are numerous ways to add a subview, I tried those. Each resulted in the leak or a blank screen.

inked
Same leak in OS 3.1.
inked
+1  A: 

Leaks has flagged open_handle_to_dylib_path in CoreGraphics for me as well; there is definitely something flagged here. Since it is merely 256 bytes at its heaviest, I fired off a bug report to Apple and called it done. You can then set a rule in Leaks' configuration to ignore the report.

As bbum pointed out, there might be serious voodoo at work. I seriously doubt Apple would let leaky frameworks go through QA -- especially since it's so easy to reproduce.

Jed Smith
A: 

Hi my name is Janos. i have Exactly the same problem.

Janos
A: 

hi, ı also wonder how it is happening, i think this is just a normal allocation not an actual leak. Dear inked, how did you manage to trace this call to addsubview.

onur
A: 

@Jed Smith: Did you hear back after filing the bug report? I have the same issue.. very annoying.

iPhoneBoy
A: 

Same problem here. Thanks for posting this, I was going nuts.

wanderlust
A: 

Hi. I am also having the same problem. Any solution to this :)

Felix
+4  A: 

Hope this helps.

From: http://www.cocos2d-iphone.org/forum/topic/2460

"The simulator has bugs related to singletons and llvm stuff that are incorrectly reported by Instruments. Always check your leaks on the device itself."

Lou
+1  A: 

This must be a bug. It appears in Apple's own example, PageControl, found here: http://developer.apple.com/iphone/library/samplecode/PageControl/index.html#//apple%5Fref/doc/uid/DTS40007795

John Middendorf
+2  A: 

Hi, I tried it on a real ipod touch. No leak was reported. Probably just a simulator thing ...

mike majid
A: 

have the same problem.. annoying.

In sim.. havent tried on device tho.

help?

Sam Jarman
A: 

Hi Friends, I had the same problem, but was able to understand why it happened. And I have given a brief info regarding this problem in this article

Might be useful for you.

Krishnan