Objective c Memory Leak related Questions - xcode

1.X-Code -> Run -> Run with Performance Tool -> Leaks i am getting a memory leak like Responsible Library :UIKit Responsible Frame:UIKeyBoardInputManagerClassForIn.When i traced it does not point to my code instead it points to some frame works.Is this issue of my code? or any chance of leak from apple's frame work?

In X-Code 3.2 I connected iPhone device and the clicked Build & Analyze the right clicked on product/press cmnd+shift+(A/B) you can see many potential leaks this is static analysis but it is showing potential leaks caused only by my code.Hope this would be helpful for some one.

This issue related to the frameworks.Not in your code.So it can't so in your code.So asper my knowledge no need to worry.

Related

Why does Titanium Alloy have so many leaks?

Why does instruments using the leaks tool show so many leaks and then crash after about three leak detection cycles?
That cannot be normal ?
The app I am testing on has one index window with one label in it which, on click opens another window which on click closes itself again.
No big deal yet it seems to have leaks ?
the first detection says 72 new leaks
the second then 8 new leaks ... ?
Does anyone know why this might be ?
Thanks for your help trying to get my head around this
Having developed apps with Titanium for 8 years now this doesn't look anything like it should. Whenever leaks are found by the community it usually is quickly fixed by the dev team. That said, it is very rare leaks are found.
Most memmory leaks are developer generated. For example if you create references to UI elements outside the controller it is in you will have to clean up the reference to that UI element to let garbage collection handle it. Garbage collection cannot trigger if you didn't free the components up.
I will not be able to help you further besides the above as you have not provided any relevant information like SDK version, code that causes it etc. You might've stumbled upon a real memory leak but chances are you're not freeing up resources.

What does “Allocated Prior to Attach” mean in Xcode instruments?

I am new to Xcode and the profiling tool, instruments. I tried to find leaks of my c program. Everything is fine. It shows no leaks, but I don’t understand some terms used in the program. Does mean I still have memory leaks somewhere else in the program?
Applications like the debugger and Instruments may hook into your program after the OS has already started it running. What the message is saying is that it doesn't know how a given piece of memory was allocated because it was allocated before Instruments hooked into your program. So it has no way to track where it came from. It may or may not mean that there are more actual leaks in your program.
I believe that you can start your program from Instruments in most cases, which I think would eliminate the issue. Once you've run it once, you should be able to press the Record button (the red circle) again and it should run the app once more. I think in that situation, it should have access to all of the allocations your app makes.
For what it's worth, I have seen this message before and had it go away during the same run. It was as if it suddenly found the data that explained where the leak came from. I've also seen it happen on one run and be gone on a subsequent run with the same data. In that case it seemed like a timing issue of Instruments and not a legitimate leak.

Memory Leak in sample project

I have downloaded the finished sample project which can be downloaded here http://www.raywenderlich.com/downloads/Cocos2DSimpleGame3_v2.zip
from Ray Wenderlichs tutorial site http://www.raywenderlich.com/25806/harder-monsters-and-more-levels-how-to-make-a-simple-iphone-game-with-cocos2d-2-x-part-3
I have put it on my device and noticed that my iphone memory got full after a while. I used xcode to test for memory leaks (product -> profile) and it showed that there are numerous memory leaks in the program. I'm very new to cocos2d so I don't know how to fix them. Is someone able to help fix these memory leak issues? Please keep in mind I'm a novice. Cheers
I know this may not be what you want, but you should consider converting the project to ARC.
What you should do is add the Cocos2d (and whatever other lib files with it) to a static library. Once this is done, convert your project to ARC using Xcode.
ARC will handle the memory management for you. When ARC is turned on, the compiler will insert the appropriate memory management statements such as retain and release messages. It is best to use ARC as the compiler has a better idea of an object's life cycle and is less prone to human error. This will also save you many potential hours scouring over that sample project.
There is a wonderful tutorial posted here on how to convert Cocos2D projects to ARC http://www.learn-cocos2d.com/2012/04/enabling-arc-cocos2d-project-howto-stepbystep-tutorialguide/

Early memory leak detection on Mac?

I am looking for ways in which memory leaks could be detected at the time of development something like a dump of leaks on console.
I am not talking about using leaks, shark, instruments. We use them after development. Sometimes finding the leaks after all development is real pain.
Thank you
When you build your app, you should always also perform "Analyze". It's available just below the build command in the menu if you use Xcode 4. This will catch almost all Objective-C leaks, and shows how an object is leaked as a curvy lines connecting the program texts.
Eliminate all warnings by the analyzer. That will solve 90% of the leak before even running your app.

Finding the leak from the Xcode 4 Profiler

My ipad app is receiving the Level 1 memory warning, so I ran the memory leak Profiler in Xcode 4. Sure enough, when I move one particular slider, it is causing a leak. Move it again, another leak and the leaked bytes escalate.
I am wondering if Xcode 4 provides an easy way to find out specifically which object is getting leaked. I have looked through the method from the slider movement; every time I use alloc/init, i then release it. It would be good know where Xcode is finding the leak since I cannot find it myself.
The Xcode 4 documentation references quite a number of tools. However I wonder if this documentation was not updated from Xcode 3 because those tools are not in the menus mentioned by the docs.
the slider action is:
-(IBAction) sensitivity:(UISlider *)slider{
self.grid.sensitivity=slider.value;
[self.grid setNeedsDisplay];
}
this by itself doesn't suggest a memory leak. However, the "setNeedsDisplay" method, which is quite a lengthy one, does not create a leak when it first runs, so why would it create a leak the second time it runs? All the inits/alloc in that code are released (there are only 3 objects created and released).
I find it useful to run Build/Build and Analyze from the Menu. It doesn't catch everything and it flags a few false alarms, but it's a good (and easy) place to start for automated leak detection.

Resources