20

In my app, I have am receiving multiple memory leaks. The object is Malloc 48 bytes, and it always originates from the responsible caller strdup. The history of the object only shows it being Malloced, and no other retains or releases. The stacktrace doesn't show any of my code. The only bits of relevance that I can pick out are:

  10 UIKit _UIGestureRecognizerSendActions
   9 UIKit -[UIScrollView handlePan:]
   8 UIKit -[UIScrollView _endPanWithEvent:]
   7 UIKit -[UIScrollView(Static) _startTimer:]
   6 CoreFoundation CFNotificationCenterAddObserver
   5 CoreFoundation _CFXNotificationRegisterObserver
   4 libnotify.dylib notify_register_dispatch
   3 libnotify.dylib notify_register_mach_port
   2 libnotify.dylib token_table_add
   1 libsystem_c.dylib strdup
   0 libsystem_c.dylib malloc

It seems to occur whilst scrolling on a map view, but I am unsure how to proceed as none of my code is referenced in the stack. How should I proceed in diagnosing this leak?

If any further information is required, please let me know.

Regards, Nick

dark_perfect
  • 1,458
  • 1
  • 23
  • 41
  • has there been any development on this? – bogardon Apr 06 '12 at 18:28
  • Sorry, I've only just gotten around to logging this. I made as simple a test app as possible, and only included a nib with an MKMapView, and was able to reproduce the leak, so I logged it with Apple under bug #11227065. – dark_perfect Apr 11 '12 at 14:55
  • This might be a known bug, also mentioned in [this SO thread][1] [1]: http://stackoverflow.com/questions/9762995/memory-leak-every-time-uiscrollview-is-released – pixelfreak Apr 13 '12 at 07:45
  • 3
    Just want to comment on this, so that nobody needs to waste any more time to wonder and look all around. This is an issue introduced in ios 5.1. The exact same leak happens in both scroll view and table view, which actually makes sense, since they must share the scroll code in one way or another. Hope it will be fixed soon. – 勿绮语 Apr 21 '12 at 03:02

4 Answers4

11

If it is "only" 48 bytes, all evidence points to frames in the system frameworks (i.e. the allocation is never exposed to your code), and there are not 10s of thousands of 'em, then I (a) wouldn't worry about it too much, but I would (b) immediately file a bug via http://bugreport.apple.com/

Attach a binary of your application and instructions as to how to reproduce the issue.

jscs
  • 63,694
  • 13
  • 151
  • 195
bbum
  • 162,346
  • 23
  • 271
  • 359
  • Hi bbum, quick reply, thanks! It is "only" 48 bytes, but they add up the more you use the map. I haven't seen this leak before (the application is into its advance stages) - would it be worth trying on a 5.0 or 4.3 simulator to see if it produces the same leak? Thanks for the advice, in any case! – dark_perfect Mar 26 '12 at 21:53
  • For these kinds of things, the simulator's behavior is often different enough to make testing there irrelevant. File the bug and post the #. This sounds, quite potentially, like a [relatively minor -- but every byte counts] leak in the frameworks. – bbum Mar 27 '12 at 03:04
  • Hi bbum, thanks I will, just trying to eliminate the possibility that it could be anything from my code. I'll post the # shortly. – dark_perfect Mar 27 '12 at 08:05
1

I think I've confirmed it was introduced in 5.1. I am able to duplicate the memory leak every time in my app by pressing the home button when my app is active with a UIScrollView as the active view using iPhone simulator 5.1. The same test running on iPhone simulator 5.0 does not reproduce the error.

Hope this helps

madZack
  • 21
  • 3
0

Just to confirm that this is indeed a reoccurring issue and not just you having a problem. I have seen this happen in Table scrolling as well as UIScrollView. I've tested it in simulator, as well as profiling the release versions on an iPad. Seems to be a common problem in 5.1 but I have yet to hear of a fix. And I do agree, 48bytes at every scroll could potentially become an issue.

Ælex
  • 14,432
  • 20
  • 88
  • 129
0

it might be caused by performselectorinbackground, call it inside of @autoreleasepool{} block

Frane Poljak
  • 2,315
  • 23
  • 25
  • but, actually i had the exact same problem and this solved it – Frane Poljak Dec 12 '12 at 11:56
  • Hi , I'm also facing same issue .. how you solve this issue . I my case . Its very simple app but when I Push and Pop view controller memory is not release . In my view controller i am using scrollview and images in it . – Vijayvir Sing Pantlia Jul 15 '16 at 07:52
  • You need to be careful not to have retain cycles. https://digitalleaves.com/blog/2015/05/demystifying-retain-cycles-in-arc/ – Frane Poljak Jul 15 '16 at 10:29