3.0 - pointer being freed was not allocated

Discussion in 'iOS Development' started by NolesFans, May 5, 2010.

  1. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    I turned on MallocStackLogging in Xcode.

    I get malloc: *** error for object 0x2068000: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug When I rotate the screen.

    I executed shell malloc_history 33465 0x2068000 from gdb then I see this

    Code:
    ALLOC 0x2058400-0x20683ff [size=65536]: thread_a04814e0 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | PurpleEventCallback | _UIApplicationHandleEvent | -[UIApplication sendEvent:] | -[UIApplication handleEvent:withNewEvent:] | -[UIDevice setOrientation:] | -[NSNotificationCenter postNotificationName:object:userInfo:] | _CFXNotificationPostNotification | _nsnote_callback | -[UIWindow _updateInterfaceOrientationFromDeviceOrientation] | -[UIWindow _setRotatableViewOrientation:duration:force:] | _CreateRotationSnapshot | UIGraphicsGetImageFromCurrentImageContext | CGBitmapContextCreateImage | create_bitmap_data_provider | malloc | malloc_zone_malloc
    it seems there is Double-Free in UIGraphicsGetImageFromCurrentImageContext
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I doubt that. I've never had any issues with that function. However, I'm not ready to dismiss your claim either.

    I know there's a small memory leak in CoreGraphics that affects PocketTouch (it has to do with the shading, as seen on the PTStatusBar and PTNavigationBars (The app leaks a total of 512 bytes during normal usage and an additional 256 bytes every time you change the theme. There's nothing I can do about that.)

    Also, and think for a moment how stupid this is, back when 2.0 came out, if you popped a UINavigationController off of the stack, it would leak its UINavigationBar. Although, to be fair, there are very few instances when anyone pushes or pops UINavigationControllers. I'll bet that almost no one ever does it, so it's understandable how that was missed by Apple.
  3. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    @OP/NolesFans: Are you sure? UIGraphicsGetImageFromCurrentImageContext returns an autoreleased UIImage, unlike UIGetScreenImage; maybe you're rereleasing it.
    BTW: Is MallocDebug referring to the image or something else?
  4. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    It is calling from _CreateRotationSnapshot. I don't called it because OS called it when you are rotating it.
  5. bddckr

    bddckr Active Member

    Joined:
    Dec 2, 2007
    Messages:
    1,434
    Likes Received:
    18
    Device:
    iPhone 4 (Black)
    Sounds like there's some view that is being rotated. Are you using autoresizingMasks? Maybe it is a subclassed UIView instance you're using that creates this problem?

Share This Page