I've finally reached the end of app creation.
I know that Instruments and Shark can be used to test for memory leaks and other such "bad stuff" in your apps. Unfortunately I can't find any good tutorials on how to use these tools.
Especially for Shark, how should I go about using these tools?
Additionally, are there any other similar tools that may be more powerful or easy to use? Thanks you!
One way to find memory leaks and other problems is to use static analysis. If you're using Xcode, there's an integrated tool that's located in Product->Analyze.
Shark is no longer really used, use the Time Profiler instrument instead.
Currently your best bet is reading through the Apple documentation on Instruments.
Related
I'm trying to figure out which parts of my app consumes the most RAM on a device.
If I use the memory graph in Xcode I see many objects and their sizes, but is there a way to somehow sort them by size? Or is there another tool that can show me this?
Edit:
I am familiar with Instruments, but for some reason the Allocations and Leaks instruments give me very odd numbers and most of the allocations appear as just mallocs. It probably has to do with the fact that I'm using Intel Multi OS Engine and most of my logic code is actually written in Java. I dumped an hprof of the java heap and watched it in Android Studio, so it gave me a good picture about the memory usage in the java side. But I wanted something for the obj-c/swift side too. Instruments is not very useful in my case.
Thanks.
You can run your program using profiler (CMD+I).
Choose "Leaks" and "Allocations" inside menu.
This tool could help you to know how much memory and which objects/processes waste the most.
These articles could help:
Working with Instruments - Allocations
Profiling Memory Allocations In iOS With Instruments
I just start using Appcelerator and I seek some information about it and I have read that Appcelerator has a huge problem with memory management and memory leaks. I would like to know if that is true before I decide to use it. Does Appcelerator have problems to manage memory?
In one word: No
It's up to you. If you code clean and reusable, Appcelerator will not have memory leaks.
I also ran into memory problems. And in 95% it was my fault.
Appcelerator had memory leaks in the past. But since SDK 4.0 the most things are done and the SDK only gets better.
Give it a try and build the example apps to have a feeling how fast Appcelerator can be.
As a titanium developer for quite a while now I haven't seen any memory problems that are caused by titanium (except for some minor issues on Android with the older versions). Available memory on mobile devices can be relatively small and with Titanium, although they work hard on reducing this, there is always an extra framework layer consuming extra memory. It's just a matter of keeping this into account and writing clean javascript with as few unneeded variables as possible left open.
There is a great guide about Titanium, Memory management and Javascript garbage collection on the Appcelerator Documentation website with good tips on how to monitor with Xcode as well.
There is also a must read article about this topic on TiDev which you should also definitely check out!
I haven't found an issue with the Titanium SDK leaking memory. Any issues have been my fault, not cleaning up a reference, not nulling, or forgetting to remove an event listener. The guides mentioned above are an excellent resource. As stated clean JavaScript keeps the maximum memory released.
I have zero iOS programming experience but I'm good with Android and Java programming. I also know my basics in C++. Here's what the app needs to do:
List out all the current running apps in the phone and display how much Ram each is consuming.
Put the ram usage by each app onto the Logger.
That's it.
It's simple enough and I've read up as much as I can about Objective C and Swift (I can use either) and I've found an interesting tool here that does something similar to what I need to do.
If any of you can give me any advice I'd be forever in debt as I really need to get this done well. If you need anything else, let me know. Thanks a bunch.
Edit: to make myself clear, I'm only asking if this is even possible in iOS and what approach I may take and if there are any tools you recommend. I'm not asking anyone to do this for me.
I am following this guide developer instrument guide and RayWenderlich's tutorial to view and analyze data using Instruments and I am wondering if anyone could suggest any other guide-tutorial as I have still unclear some aspects (e.g. how to determine which classes are live in memory at a particular frame and their memory footprint).
Thanks!
Has been few days since I posted this question and in the meanwhile I found this very useful post that gives a basic introcuction on Instruments as well as other performance related optimizations I was doing without understanding fully why :).. very useful!
I would like to be able to profile a particular C function within an iOS application to see which CPU instructions it uses, and how often they are used. What is a simple way to go about doing this?
You'll want to check out the Time Profiler tool in Instruments. Check out the User Guide for some detailed information on how to best make use of it.