Re: NSButtonCell image leaking? [SOLVED]

  • The leak I was having seem to be a false positive from "leaks". Also the
    fact that the memory was constantly growing (as I was observing it from top)
    was due to the fact that I had MallocStackLogging=1 which probably adds a
    memory overhead to keep track of memory usage.
    thanks you all,
    Giovanni

    On 9/4/07, Giovanni Donelli <giovanni.donelli...> wrote:
    >
    > Dear All,
    > I am working on app with a bunch of NSButtons on a transparent window.
    > NSButtons have different size and all contain an image that is changed
    > frequently. These images are icons of a set of files ([[NSWorkspace
    > sharedWorkspace] iconForFile:aPath]), all images once loaded are cached.
    >
    > Now the memory use of my app constantly rise as the images change. (I see
    > that in top).
    >
    >
    > If I run leaks on it, I see 4 or 5 leaks (not as many as I expected)
    > regarding, I think NSButtonCell drawing sub-routines.
    >
    >
    > Any idea what's happening and how to prevent this leak?
    >
    >
    > Thanks!
    > Giovanni
    >
    >
    >
    > Leak: 0x018ac400  size=4608
    > 0xa8c28caa 0x45f9e0d0 0x77190954 0x8769a13d    .......ET..w=.i.
    > 0x21e7d498 0xac2f6f54 0xc75fbfac 0xac599981    ...!To/..._...Y.
    > 0x391d337a 0x455fc33e 0xfa9ba0a5 0x5f07378c    z3.9>._E.....7._
    > 0xcf99443b 0xd1a8696f 0x065580bb 0x5ad78b6a    ;D..oi....U.j..Z
    > 0x00b4312d 0x87ca7cdc 0x714bcae4 0xd001941d    -1...|....Kq....
    > 0x2d78b73f 0x26cdbd14 0xcd56fe46 0xbbe57102    ?.x-...&F.V..q..
    > 0x40537460 0x8fbe5557 0xb8898a02 0x47397471    `<tS...>
    > 0xa5653de5 0x2c10b686 0x19cf9a84 0x0a061fee    .=e....,........
    > ...
    > [STACK TRACE CUT]
    >
    >
    > | -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRec
    > tForView:]
    > | -[NSNextStepFrame _recursiveDisplayRectIfNeededIg
    > noringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    > | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect
    > :rectIsVisibleRectForView:topView:]
    > | -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
    > | -[NSView _drawRect:clip:]
    > | -[NSView _regionForOpaqueDescendants:forMove:]
    > | -[NSView _regionForOpaqueDescendants:forMove:]
    > | -[NSButtonCell isOpaque]
    > | -[NSButtonCell(NSButtonCellPrivate) _imagesHaveAlpha]
    > | -[NSImage _asIconHasAlpha]
    > | -[NSImage _expand]
    > | -[NSImage _expandRep:]
    > | PlotIconRefInCGContext
    > | PlotIconRefInContext
    > | PlotISImageRefInContext(void*, CGContext*, CGRect, short, short,
    > RGBColor const*, unsigned long, _ISImageRefCallbacks const*)
    > | ISGetCGImageRefForISImageRef(void*, CGSize, short, RGBColor const*,
    > unsigned long, _ISImageRefCallbacks const*, CGRect*)
    > | ISImageRefIterator(void*, unsigned char, short (*)(void*, void*), void*)
    > | _ISGoThruImageStorages
    > | MergeBestStorageIntoContext(void*, void*)
    > | CreateCGImageRefFromBitmapInfo(_ISBitmapImageInfo*, unsigned char)
    > | _cg_JP2SimpleDecompress | _cg_JP2SimpleDecompressAlloc |
    > _cg_JP2DecompressBand
    > | kd_synthesis::pull(kdu_line_buf&, bool) | kd_synthesis::horizontal
    > _synthesis(kd_line_cosets&)
    > | kd_synthesis::pull(kdu_line_buf&, bool) | kd_synthesis::horizontal_synthesis(kd_line_cosets&)
    >
    > | kd_synthesis::pull(kdu_line_buf&, bool) | kd_synthesis::horizontal
    > _synthesis(kd_line_cosets&)
    > | kd_synthesis::pull(kdu_line_buf&, bool) | kd_synthesis::horizontal_synthesis(kd_line_cosets&)
    >
    > | kd_synthesis::pull(kdu_line_buf&, bool) | kd_synthesis::horizontal
    > _synthesis(kd_line_cosets&)
    > | kd_decoder::pull(kdu_line_buf&, bool) | kd_decoder::decode_row_of
    > _blocks()
    > | kdu_subband::open_block(kdu_coords, int*) | kd_block::retrieve_data(kdu_block*,
    > int)
    > | kdu_block::set_max_bytes(int, bool)
    > | operator new[](unsigned long) | operator new(unsigned long) | malloc
    >
    >
    >
  • On Sep 4, 2007, at 2:58 PM, Giovanni Donelli wrote:
    > The leak I was having seem to be a false positive from "leaks".
    > Also the
    > fact that the memory was constantly growing (as I was observing it
    > from top)
    > was due to the fact that I had MallocStackLogging=1 which probably
    > adds a
    > memory overhead to keep track of memory usage.

    Yup -- MallocStackLogging will make the heap grow a bit with every
    allocation or deallocation event.  Very very useful debugging tool
    -- but very expensive.

    You can reduce the number of false positives emitted by "leaks" by
    turning on malloc scribbling.  See the malloc man page and look for
    MallocScribble and MallocPreScribble.

    It does what the name implies -- scribbles a known byte pattern on
    hunks of memory at allocation time and after deallocation.  This'll
    bust programs that are reading from said uninitialized memory.  It'll
    also help "leaks" in that it no longer will see pointers left over
    from previous use of the memory.

    You can still end up with false positives, but many many fewer.

    b.bum
previous month september 2007 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
Go to today