Re: Memory usage: Xcode vs. Instruments, who is right?
Re: Memory usage: Xcode vs. Instruments, who is right?
- Subject: Re: Memory usage: Xcode vs. Instruments, who is right?
- From: Han Ming Ong <email@hidden>
- Date: Fri, 06 Dec 2013 21:45:22 -0800
On Dec 6, 2013, at 2:20 PM, Markus Spoettl <email@hidden> wrote:
> Han Ming,
>
> thanks a lot for the details. I don't mind if Xcode gets it wrong (or not as right as Instruments), so long as there's a really reliable way to find out what the real usage is.
>
> So, just to be absolutely sure: The value in the "All Heap & Anonymous VM" line (top) in the "Live Bytes" column in the allocations instrument is showing the real current memory usage, right?
Yes, Instruments shows you how much memory your app is using now.
Xcode’s memory report shows you how much memory is still assigned to your app. It is good for showing memory usage trends. Here are a couple of examples
- let’s say your iOS app allows the user to select and show a photo. Before a new photo is shown, you make sure that there are no strong pointers to the old photo. But yet, every time a new photo is shown, the Xcode memory report shows that memory usage is monotonously increasing.
- you have noticed that your iOS app memory usage is about 500MB after a certain user test scenario. But after a major refactoring, it has jumped 20% to 600MB, doing the exact user test scenario.
In both examples, Xcode lets know you that something is probably wrong with your memory management. Because you know your code well, you may be able to figure out the problem by reviewing your code. If not, you can easily launch Instruments and look at the allocation/deallocation patterns.
Hope that answers your question.
>
> Regards
> Markus
>
> On 12/6/13 10:45 PM, Han Ming Ong wrote:
>> Markus,
>>
>> If your app is running on the Mac, Xcode’s memory report will show the same
>> number as Activity Monitor’s ‘Memory’ number. That’s because Xcode and
>> Activity Monitor (for that matter, /usr/bin/top) make the same system call to
>> understand your app’s memory usage. Of course we don’t have Activity Monitor
>> nor ‘top’ for your iOS app. Regardless, Xcode makes the same system call on
>> iOS to get your app’s memory usage. One of the reasons that you don’t see the
>> memory drop could be because the system has not reclaimed the freed memory
>> from your app. It uses different heuristics to make that determination. Try
>> this : when your app is running and you switch to another app that consumes a
>> lot of memory, check if Xcode reports a drop in memory usage. I wouldn’t rule
>> out a bug in Xcode’s implementation and so please file a bug if you think
>> there is a problem. We would love to investigate the issue.
>>
>> Xcode records a lot less because it doesn’t want to slow down the target
>> application since you are not in a ‘profiling’ mode per se. Instruments
>> records a lot more info and can know when objects are allocated/deallocated.
>> It can let you know accurately if your application is leaking memory.
>>
>> I’m not surprised that both Xcode and Instruments report the same high water
>> mark.
>>
>> In summary, Xcode gives you a live picture of your memory usage trend.
>> Instruments allows you to deep dive to confirm if you are leaking memory or
>> not.
>>
>> Han Ming
>>
>>
>> On Dec 6, 2013, at 10:45 AM, Markus Spoettl <email@hidden>
>> wrote:
>>
>>> Hi,
>>>
>>> I'm trying to understand Xcode 5's memory utilization report pane. When I
>>> debug my iOS app (on the device), memory usage as reported by Xcode almost
>>> never goes down, while when using Instruments' Allocations instrument, mem
>>> usage goes up and down as objects are allocated or deallocated.
>>>
>>> Top mem usage is the same for both variants.
>>>
>>> Of course I expect differences (Xcode runs a debug version, Instruments
>>> runs the optimized release build), but Xcode makes it look as though I leak
>>> most of the allocated memory, where the leak instrument tells me everything
>>> is alright.
>>>
>>> Can I just ignore the memory pane in Xcode?
>>>
>>> I'm using Xcode 5.0.2.
>>>
>>> Regards Markus -- __________________________________________ Markus
>>> Spoettl _______________________________________________ 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
>>
>>
>
>
> --
> __________________________________________
> Markus Spoettl
_______________________________________________
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