Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding memory leaks while running iPhone unit tests

I know how to do Unit Test on iPhone - the logic tests which run during build phase of the "iPhone Unit Test Bundle".

I know how to detect memory leaks using instruments - in XCode, Menu->Run->run with perf tools->Leaks.

How do I do both? I want to run the unit tests and detect memory leaks in them. If I try to simply select unit-test bundle as target and then "Menu->Run->run with perf tools->Leaks" I get the app loading in simulator but the unit test is not run.

The best I could come up with is include the same unit-test files into my real app target and simply invoke them all from the app itself at runtime. Any better ideas?

like image 406
DenNukem Avatar asked Dec 07 '09 01:12

DenNukem


People also ask

How do you detect a memory leak in performance testing?

The best approach to checking for the existence of a memory leak in your application is by looking at your RAM usage and investigating the total amount of memory been used versus the total amount available. Evidently, it is advisable to obtain snapshots of your memory's heap dump while in a production environment.

How do I find a memory leak on my Iphone?

To detect memory leaks you should run the app and navigate through all possible flows and open several times the same view controllers, then enter memory graph debugger and look at the memory heap. Look for objects that shouldn't be in memory, for example: A view controller that is no longer present in the app.

What test is used to detect memory leaks?

Any new illegal uses of memory and memory leaks are detected and reported through the CI system. The CI system's test reports provide transparency to a problem that is often undetected until it is too late. Generation of memory result files allows for follow-on detailed analysis of the application's use of memory.


1 Answers

There's really no need to check for leaks because they're started up and torn down independently. If you're trying to debug a leak by running the unit tests and seeing if they leak, you're probably better off using something like the clang static analyzer in Xcode 3.2

like image 200
refulgentis Avatar answered Oct 22 '22 00:10

refulgentis