tomkaith13
tomkaith13

Reputation: 1727

How should I interpret the "all allocations" data in the Leaks Instrument?

I have written an app and was testing it for memory leaks when I noticed that the "all allocations" category in the leaks simulator keeps increasing its size whenever I open and close a sub-view.

I intially thought it was a memory leak, but it does not show up as a leak in the leaks tab.

Is this normal?

Screenshot of the simulator

Upvotes: 2

Views: 1061

Answers (2)

Positronic Matrix
Positronic Matrix

Reputation: 33

It depends which column of the table you are looking at.

The 'Overall' and 'Overall Bytes' figures will always go up, since they are a running count of allocations made with no account of deallocations.

However, the 'Live Bytes' and '# Living' figures should go up when an object or block of memory has been allocated, but should go down when they are deallocated.

Repeatedly opening and closing a sub-view should (subject to image or data caching) hover around a fixed number of live bytes and living objects / memory blocks.

Instruments sometimes gets a bit confused, however, as you can see from the screenshot. The whole '# Transitory' column is showing '0', which is obviously incorrect. A transitory object is just one that has been allocated and subsequently deallocated, i.e. it's a non-living object.

(# Living + # Transitory == # Overall)

Whenever Instruments gives me that column of zeros, I quit the current run and start a new one.

As for the Leaks Instrument, it will only show those objects or memory blocks that no longer have any pointers pointing to them. If a program continually allocates more and more objects / memory blocks but retains pointers to them, the Leaks Instrument won't show them.

Upvotes: 3

sciritai
sciritai

Reputation: 3758

That would make sense would it not? Every time you do something in the app, something is probably allocated such as your different subviews. Therefore total allocations will increase.It's just a record of the total allocations.

Upvotes: 1

Related Questions