Organizational Research By

Surprising Reserch Topic

memory leak every time uiscrollview is released

memory leak every time uiscrollview is released  using -'ios,memory-leaks,uiscrollview,instruments'

In my app I have a scroll view and four table views. Each time one is dragged and then released, I get a 48 byte leak. This really adds up. As you can see, both groups of leaks have the same source. Has anyone seen a leak like this before?

Edit 1:

When I click on the arrow next to the leak, I get this information for the leak:


asked Sep 15, 2015 by LouiseHuot47
0 votes

Related Hot Questions

4 Answers

0 votes

What you are seeing is a known bug in iOS 5.1 and is being discussed in the iOS Developer Forums as such. You can find the relevant thread by searching in the forums for "strdup". See the thread titled "Elements App Memory Leak". Search for the post from an Apple employee.

answered Sep 15, 2015 by CasPfeffer
0 votes

Most likely, it's your fault, somehow.

In the Allocations instrument, press the "i" button and turn on "Record Reference Counts". Then Instruments can show you all the allocation, retain, autorelease, and release events that happened to those objects. (You should see an arrow next to each leaked item -- click it to show the allocation history of that object.)

I think you'll find that some of your code is retaining something, or indirectly causing it to be retained. Probably the scroll view or one of its gesture recognizers, as a guess.

answered Sep 15, 2015 by BrandonDNBY
0 votes

A workaround:

I realised that somehow this leaked bytes are stored within the scrollview. You have to release your scrollview and alloc it again from time to time, keeping its state. The way you detect when you should reload the scrollview is up to you, depends on your app needs. Every time you release the scrollview, these bytes are also released.

answered Sep 15, 2015 by MarCremean
0 votes

Workaround: I found that the memory leak occurred in handlePan: if the UIScrollView delegate is set. I needed the delegate methods, so I subclassed UIScrollView, and declared my own @protocol. Then I overrode the target selector for the scrollView panGestureRecognizer, without sending it to super:

@protocol yourScrollViewDelegate

   [yourDelegate yourProtocol];
answered Sep 15, 2015 by KimG72