Huge increase in memory usage on Leopard

  • I found that my app is using 5-9 times more memory in Leopard
    compared with Tiger. The memory during typical usage on Tiger on G5
    with 1.5G RAM is about 21MB (RSIZE), 14M (RPRVT). In Leopard on the
    same machine, the memory reach each 180MB (RSIZE). On another
    machine, Mac mini solo with 512MB RAM, the memory is about 100MB
    (RSIZE), 50MB (RPRVT) with Leopard.

    I profiled the app with Instruments on the G5 and found that memory
    allocated by NSBitmapImageRep (using _NSImageMalloc) is not freed
    when the instance is released. This is not a leak - the system seems
    to keep a pool of 14 allocations (each around 7MB) and reuse this
    pool. I see this for each NSBitmapImageRep I create.

    This happens when creating NSBitmapImageRep with
    initWithBitmapDataPlanes:NULL. I can work around this by allocating
    my own memory and creating the instance with my memory. After moving
    to manual memory allocation for the bitmaps, the memory size on the
    Mac mini went down to 36MB (RSIZE), but the same code on Tiger takes
    now only 14MB (RSIZE). The profile does not show any more "big"
    allocations I can fix, except the NSBitmapImageReps allocations.

    One smaller but similar allocation happen each time a bitmap is
    processed with CoreImage. Each call to CIContext
    drawImage:atPoint:fromRect: allocate about 1MB which are not freed.
    There seems to be a similar pool of those 1MB chunks.

    I found similar behavior with Apple Reducer example code <http://>. It run with 50-60MB on
    Tiger, but reach about 150MB in Leopard after 20-30 operations on the
    same image. My app use similar code to process bitmaps.

    The application is built on Tiger. Rebuilding on Leopard with Xcode 3
    did not change anything.

    Anyone has a clue what is going on?

    Best Regards,

    Nir Soffer
previous month november 2007 next month
      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