Re: Leaks instrument
Re: Leaks instrument
- Subject: Re: Leaks instrument
- From: Ken Thomases <email@hidden>
- Date: Wed, 17 Feb 2010 16:33:35 -0600
On Feb 17, 2010, at 4:03 PM, Owen Hartnett wrote:
> Is it something I'm doing, or is the leaks instrument getting slowly less useful as an iPhone tool?
>
> I'm trying to check for leaks with it. I get 6 or so small leaks that are permanent (mostly the 3.5K of that The timeline is showing small orange blips but no additional leaks are added. I'm doing minor operations trying to prod it into revealing something. My total allocations run about 2.7 megabytes. My app gets a low memory error. All I've really got going is a webview. Shortly thereafter, the app just shuts down - looks like it's out of memory.
>
> I've been relying more on the code analyzer than the leaks tool to find problems. I'm just wondering if people are getting similar results and/or this behavior is typical or I'm doing something wrong.
I don't do iPhone development, and I'm not sure about the situation you're seeing, but...
In general, there are some "leaks" which aren't detectable by the Leaks instrument. Technically, your app might not be truly leaking the data, just accumulating it and never releasing it or using it again.
For example, you might be adding items to a mutable array. At one time, you meant to do something with the contents of the array and then empty it, but your code has evolved such that it doesn't do that anymore. However, it's still adding things to it. So, there are no objects which are unreachable, but you just keep adding them to this array and forgetting about them.
That's of course just one contrived example. The principle is that you could be doing something which is neither a violation of memory management guidelines nor leaving objects unreachable, so neither the static analyzer nor the Leaks instrument will tell you about them. But it will still cause your app's memory usage to grow and grow.
The built-in Leaks template also includes the ObjectAlloc instrument. You can use that to see what objects are still around that shouldn't be. You can sort its summary view by allocation count or overall bytes. You can select a range in the timeline over which your app's memory usage should be stable -- that is, from point A to point B it might vary (increase) but by point B it should be back to where it was at point A. Then, you can look at what objects were created during that interval that are still living at its end. Etc.
Cheers and good luck,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden