Is it 'normal' that scrolling in a UIScrollView leaks some bytes?

  • I can answer it myself: no, it should not be considered normal that an app leaks memory, and that is why it makes me quite nervous.

    What happens is this:

    In an iPad / iPhone project I present a few UIImageViews on-screen. They are contained within their own UIScrollViews as I want to zoom in and out and scroll on them. I still have to work in the iOS Simulator because I am waiting for approval to provision my devices, but still testing seems to work fine. I can display images inside the views, and using keyboard modifiers I can emulate the standard gestures for zooming and scrolling, which al works perfectly.

    Sometimes, just sometimes, when I scroll an image beyond its content size (you can see the animating bouncing back and forth of the image inside the UIScrollView), Instruments reports a memory leak of only small number of bytes. These are not leaked images I created, it must be something deeper within the UIKit I guess.

    It tells me something like this:

    Leaked Object: Malloc 48 Bytes
    Address: any pointer to the leaked 48 Bytes
    Size: 48 Bytes
    Responsible Library: libsystem_c.dylib
    Responsible Frame: strdup

    Do you guys recognize this behavior? And should I get that nervous, or is it not an issue at all? (That is highly unlikely but I can ask, right?)

    Thank you for any insights.

    [[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];
  • I believe this is a known bug in UIScrollview (search for "strdup leak in UIScrollview"). Wouldn't hurt to file a bug with Apple (which will probably be marked a duplicate).

    Aaron

    On Jul 24, 2012, at 10:28 AM, Richard Altenburg (Brainchild) wrote:

    > I can answer it myself: no, it should not be considered normal that an app leaks memory, and that is why it makes me quite nervous.
    >
    > What happens is this:
    >
    > In an iPad / iPhone project I present a few UIImageViews on-screen. They are contained within their own UIScrollViews as I want to zoom in and out and scroll on them. I still have to work in the iOS Simulator because I am waiting for approval to provision my devices, but still testing seems to work fine. I can display images inside the views, and using keyboard modifiers I can emulate the standard gestures for zooming and scrolling, which al works perfectly.
    >
    > Sometimes, just sometimes, when I scroll an image beyond its content size (you can see the animating bouncing back and forth of the image inside the UIScrollView), Instruments reports a memory leak of only small number of bytes. These are not leaked images I created, it must be something deeper within the UIKit I guess.
    >
    > It tells me something like this:
    >
    >
    > Leaked Object: Malloc 48 Bytes
    > Address: any pointer to the leaked 48 Bytes
    > Size: 48 Bytes
    > Responsible Library: libsystem_c.dylib
    > Responsible Frame: strdup
    >
    >
    > Do you guys recognize this behavior? And should I get that nervous, or is it not an issue at all? (That is highly unlikely but I can ask, right?)
    >
    > Thank you for any insights.
    >
    >
    > [[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];
    >
  • Op 24 jul. 2012, om 19:28 heeft Richard Altenburg (Brainchild) het volgende geschreven:

    > Leaked Object: Malloc 48 Bytes

    Here is a deep copy of the call stack inside which this leak happened:

    Bytes Used    # Leaks        Symbol Name
        48 Bytes  100.0%    1         main
        48 Bytes  100.0%    1          UIApplicationMain
        48 Bytes  100.0%    1           GSEventRun
        48 Bytes  100.0%    1           GSEventRunModal
        48 Bytes  100.0%    1             CFRunLoopRunInMode
        48 Bytes  100.0%    1             CFRunLoopRunSpecific
        48 Bytes  100.0%    1               __CFRunLoopRun
        48 Bytes  100.0%    1               __CFRunLoopDoSource1
        48 Bytes  100.0%    1                 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
        48 Bytes  100.0%    1                 PurpleEventCallback
        48 Bytes  100.0%    1                   _UIApplicationHandleEvent
        48 Bytes  100.0%    1                   -[UIApplication sendEvent:]
        48 Bytes  100.0%    1                     -[UIWindow sendEvent:]
        48 Bytes  100.0%    1                     -[UIWindow _sendGesturesForEvent:]
        48 Bytes  100.0%    1                       _UIGestureRecognizerUpdate
        48 Bytes  100.0%    1                       _UIGestureRecognizerApplyBlocksToArray
        48 Bytes  100.0%    1                         ___UIGestureRecognizerUpdate_block_invoke_0541
        48 Bytes  100.0%    1                         -[UIGestureRecognizer _delayedUpdateGesture]
        48 Bytes  100.0%    1                           -[UIGestureRecognizer _updateGestureWithEvent:]
        48 Bytes  100.0%    1                           _UIGestureRecognizerSendActions
        48 Bytes  100.0%    1                             -[UIScrollView handlePan:]
        48 Bytes  100.0%    1                             -[UIScrollView _endPanWithEvent:]
        48 Bytes  100.0%    1                               -[UIScrollView(Static) _startTimer:]
        48 Bytes  100.0%    1                               CFNotificationCenterAddObserver
        48 Bytes  100.0%    1                                 _CFXNotificationRegisterObserver
        48 Bytes  100.0%    1                                 notify_register_dispatch
        48 Bytes  100.0%    1                                   notify_register_mach_port
        48 Bytes  100.0%    1                                   token_table_add
        48 Bytes  100.0%    1                                     strdup
        48 Bytes  100.0%    1                                     malloc
  • Thank you Aaron and Julius for pointing out it is a known bug. I can not check the developer forums as I am not on a developer program just yet. I should have checked by searching on the web, sorry that this time I poured my problem right into the mailing list.

    As this is a known bug, Apple won't shoot my app for it probably, and those few bytes missing won't hurt my end users too, so I can move on to the next step in my project. Thanks again.

    [[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];

    Op 24 jul. 2012, om 19:34 heeft Eeyore het volgende geschreven:

    > I believe this is a known bug in UIScrollview (search for "strdup leak in UIScrollview"). Wouldn't hurt to file a bug with Apple (which will probably be marked a duplicate).
previous month july 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today