NSImage Memory Management: To Page Or Not To Page.

  • I am building an app that scrolls through a large amount of NSImages.
    Should I be deallocating images at some point to avoid paging, or
    should I allow the system to manage these images by allowing paging?

    If I need to create my own memory management for these NSImages, how
    can I tell when I my app will begin paging, as to avoid it by
    deallocating the NSImages?
  • On 15 Oct 06, at 08:07, Jordan Evans wrote:
    > I am building an app that scrolls through a large amount of NSImages.
    > Should I be deallocating images at some point to avoid paging, or
    > should I allow the system to manage these images by allowing paging?
    >
    > If I need to create my own memory management for these NSImages, how
    > can I tell when I my app will begin paging, as to avoid it by
    > deallocating the NSImages?

    Do your own memory management. Forcing the system to swap out parts of
    your program's memory will make it force other programs out as well,
    which will lead to a significant slowdown when those programs are
    reactivated.

    The specifics are likely to be a bit of a black art. Best strategy is
    probably to figure out how much physical memory the machine has, then
    limit the cache to some percentage of that. If you feel like being
    really good about it, add a preference setting for what that
    percentage should be.
  • On Oct 15, 2006, at 1:16 PM, Andrew Farmer wrote:

    >> If I need to create my own memory management for these NSImages, how
    >> can I tell when I my app will begin paging, as to avoid it by
    >> deallocating the NSImages?
    >
    > Do your own memory management. Forcing the system to swap out parts of
    > your program's memory will make it force other programs out as well,
    > which will lead to a significant slowdown when those programs are
    > reactivated.

    The data structures in the ImageIO framework can load image headers,
    thumbnails, previews, and so on without loading the actual backing
    images. In other words, you can treat the images as lightweight
    references, potentially saving tons of memory and CPU time.

    (For what it's worth, credit for me knowing this goes to Josh Anon).

        - Scott
previous month october 2006 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