How can I use the 'leaks' command line tool on an application running in a device? - ios7

I want to use the leaks command-line tool to analyse my leaks. I initially used Instruments, but somehow all the leaks were solved. Later, the app got rejected, giving leaks as the issue.
From the logs, I learnt that the leaks tool is being used to test instead of Instruments, and finding leaks which are not being shown in Instruments.
Can anybody help me with this?
Also, I don't have and don't want to use a jailbroken device.

Related

Is it possible to set a baseline memory usage in valgrind for leak detection?

Is there a way to tell valgrind from inside my code when to start and when to stop checking for memory leaks?
I am using a legacy testing framework which must link with my testing program in order to run. The framework has memory leaks in it - valgrind shows about 50KB of memory that has not been released, but is reachable via heuristic. This is annoying, because I must keep this number in mind to see how much memory is leaked from my code. It would be a lot more convenient if I could tell valgrind to start collecting memory stats when my first test begins, and stop collecting when the last test is over. Is there an API for it?
valgrind memcheck allows to do a "differential" leak search. The differential leak search reports the delta between the previous leak search and the current situation.
You can do such a differential leak search using monitor commands with vgdb, either from the shell or from gdb. See https://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands.
You can also use the client request VALGRIND_DO_CHANGED_LEAK_CHECK from your program, see https://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs.

Debugging methods for finding the location and error that's causing a game to freeze

I recently I came across an error that I cannot understand. The game I'm developing using Cocos2D just freezes at a certain random point -- it gets a SIGSTOP -- and I cannot find the reason. What tool can I use (and how do I use it) to find out where the error occurs and what's causing it?
Jeremy's suggestion to stop in the debugger is a good one.
There's a really quick way to investigate a freeze (or any performance issue), especially when it's not easy to reproduce. You have to have a terminal handy (so you'll need to be running in the iOS simulator or on Mac OS X, not on an iOS device).
When the hang occurs pop over to a terminal and run:
sample YourProgramName
(If there are spaces in your program name wrap that in quotes like sample "My Awesome Game".) The output of sample is a log showing where your program is spending time, and if your program is actually hung, it will be pretty obvious which functions are stuck.
I disagree with Aaron Golden's answer above as running on a device is extremely useful in order to have a real-case scenario of where the app freezes. The simulator has more memory and does not reproduce the hardware of the device in an accurate way (for example, the frame rate is in certain cases lower).
"Obviously", you need to connect your device (with a developer profile) on Xcode and look at the console terminal to look for traces that user #AaronGolden suggested.
If those are not enough you might want to enable a general exception breakpoint in Xcode to capture more of the stacktrace messages.
When I started learning Cocos2D my app often frooze. This is a list of common causes:
I wasn't using sprite sheets and hence the frame rate was dropping drammatically
I was using too much memory (too many high-definition sprites. Have a look at TexturePacker and use pvr.ccz or pvr.gz format; it cuts memory allocation in half)
Use instruments to profile your app for memory warnings (for example, look at allocation instruments and look for memory warnings).

Xcode Memory Leaks detection in Unit Test

Is it possible to test if memory leaks occur when running a Unit Test?
I want to check if my memory management is handled correctly.
Thanks
You can try running your unit tests under Instruments with the Leak Detection Instrument.
However, this will only work for Application (bundle) tests, if you're using OCUnit. If you happen to use something else, please let us know.

iOS app eating nearly 40mb at start

Hey, now when I finally got to test my app on a device it eats 40mb memory at the beginning which is a huge amount. Is there any good way to determine where exactly things went wrong?
Yes, use the memory allocations and leaks profilers that are part of the Instruments application.
You'll probably want to profile it using the Instruments app that comes with Xcode.

Application Crashes due to Low memory

My app crashes after playing for more than 30 min on some screen due to low memory will my app get reject due to this?
actually i tried a lot to solve but it shows no trace in instrument i even did all permutation combination of code by commenting checking what causing the problem but i was not successful to solve it yet.
its an ipad application 3.2 sdk
I have notice many app which crash due to low memory and they are happily on app store
Any clues,suggestion ,advice will be appreciated.
Thanks in advance
Bill Bumgarner recently wrote up a blog post on using Heapshot Analysis to catch memory growth when some of the more traditional techniques fail. Although his write up is in the context of a Mac OS application, the technique should be equally applicable to iOS. Bill walks you through using the Allocations Instrument to do Heapshot Analysis and track down your leak.
Perhaps this technique will help you track down your memory issues.
See bbum's weblog-o-mat » Blog Archive » When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth