Memory leak every time UIScrollView is released

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:


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.

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.

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.

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];

Need Your Help

How to zip and unzip the files?

android file zip unzip

How to zip and unzip the files which are all already in DDMS : data/data/mypackage/files/ I need a simple example for that. I've already search related to zip and unzip. But, no one example availab...

Running SSL node.js server with godaddy gd_bundle.crt

node.js ssl https x509

I am having trouble getting my SSL server working with the certificate's from godaddy