Search code examples
iosobjective-ccocoa-touchinstruments

occupied memory increased continuously, but no memory leak


I developed an app to download web pages from a site. For the huge web site, it will run a long time. I noticed that the occupied memory increased continuously(from 30M to 300M after download 2600 web pages), but there is no any memory leak in Instrument.

enter image description here

enter image description here

after download 3648 web pages, its info

enter image description here

enter image description here

After I stop the download procedure, occupied memory do not decrease for memory releasing.

I change all code

[NSString stringWithFormat:@"someThing"];

to

[[NSString alloc] initWithFormat:@"someThing"];

a little improvement, occupied memory drops to 300m

your comment welcome


Solution

  • This chart is the total number of allocations, not the current memory usage. The "persistent" column (allocations that haven't been released) is around 40MB. What it's telling you is that you have allocated at various times about 5.68GB of data and released almost all of it. That's why the red bar is almost entirely pale red, with just a little solid red on the left.

    This suggests there may be ways to improve performance by reusing more memory rather than allocating and releasing it (which is very time-consuming). Or perhaps by avoiding unnecessary temporary allocations. But if you're not having a performance issue, there's no actual problem here.