Xcode 5 Debugg Navigator Memory disagrees with tools

I am working on my first ARC and Core Data project, based on this step on the Master-Detail Xcode (Universal) template. I note that Xcode5 has a memory mapping in Debug Navigator, but when I use it, it finds that its graph has little to do with using mem displayed in Tools when starting Leaks & Allocations trace. I traced the tools using the Simulator (simulating both the iPhone and iPad - in case the โ€œunloadingโ€ of the View part with the latter matters), as well as on iPad2 and iPodTouch. The results are generally the same:

iPhone 6.1 simulator

  • Generation A -------- 1.13 MB
  • Generation B -------- 397.70 KB
  • Generation C -------- 76.96 KB
  • Generation D -------- 11.70 KB
  • Generation E -------- 1.56 KB
  • Generation F -------- 3.48 KB

overall growth c30%

where Generation A shows the load growth of the main table, and each subsequent generation increased after viewing the details and interacting with it (as a result of fetching NSManagedObjects and creating NSObjects, respectively). The growth trend with other devices was generally similar (with the growth of generation A there was an iPad sim: 1.42, iPad2: 1.57, iPodTouch: 0.94, but with a similar lag).

According to the Debug Navigator, however, using everything at every point occurs through:

iPhone 6.1 Debug Navigator

  • Generation A -------- 4.2 MB
  • Generation B -------- 6.9 MB - growth 2.7
  • Generation C -------- 7.1 MB - growth 0.2
  • Generation D -------- 7.8 MB - growth 0.7
  • Generation E -------- 8.0 MB - growth 0.2
  • Generation F -------- 8.4 MB - growth 0.4
    overall growth of 100%!

Referring to other similar questions, I do not have Zombies. Have others seen such discrepancies? Am I correctly inclined to trust tools over the Debug Navigator aggregate metric?

PS. The total amount of Debug Navigator does not seem to be available when starting up real devices (as in iOS5 versions). This is normal?

+4
source share
1 answer

This may not be a very good answer for you, but it is my justification for this problem in the research that I did.

The debug navigator shows the same things as the Activity Monitor tool. The application does not display the current allocated memory, displaying the current memory available to your application by the operating system.

Let's say I create a for loop to create a large number of objects in memory, but then I delete half of them because they do not match my search criteria (poor coding, I know, but hypothetically here). The OS will receive a request from your application for full memory to create all the objects, but after the cycle, when you check your allocations in the tools, only the stored objects are displayed, because the garbage collection took out the deleted ones. The OS may or may not know about garbage collection events, but it does not take up the memory that it just gave you. I'm not sure about the overhead of providing / getting available memory from your application, but I'm sure they take that into account. I noticed that if I leave my application long enough, the OS will take up some of the memory that I do not use.

Think of debugging memory information as the full application memory allocated by the OS. You cannot use all this, but the OS gave it to you anyway (for one reason or another). This number will increase depending on your requests / application usage. It will decrease due to memory alerts or inactivity that the OS thinks that it can safely recover memory from you. This will probably never correspond to the memory information allocated by the tools, because there is always temporary memory used in applications that need to be placed somewhere even for a short time.

Again, this is my conclusion, based on when I was interested in the same thing as you. Hope this helps a bit.

+9
source

All Articles