Re: Memory usage
Re: Memory usage
- Subject: Re: Memory usage
- From: Matt Neuburg <email@hidden>
- Date: Thu, 24 Mar 2005 17:24:37 -0800
On Fri, 25 Mar 2005 00:39:37 +0100, Michael Becker <email@hidden>
said:
>Hi!
>
>I am not sure if this is the appropriate list to post this, but I am
>sure people here can answer my question. I have an application that
>reads out and displays the iPhoto library. After selecting one of the
>albums, the images of this album are read from disk and displayed. So
>far, everything works fine, but I just checked my memory usage with the
>command-line tool "top".
>
>I must admit that I am in no ways a memory expert, so there may be
>wrong assumptions here. What worries me the most is, that unlike
>iPhoto, my app's stats grow worse over time. That means, if I change
>between the albums, each of the numbers in top grows. Although I am
>properly releasing my objects, it seems as memory usage increases.
>
>In my list, every running app uses at most about 400 REGS (memory
>regions). But my app (after some album switching) easily reaches more
>than 1500 of those.
>
>Now here is the question: Why does my app increase in memory usage even
>though I properly facilitate Cocoa's memory management? Say, I have 100
>images in the current album view. When I switch the album, those 100
>images are released, then the new album's images are read from disk. If
>the new album only has 10 images, shouldn't that drop my mem-usage?
>
>I'm sorry if I am asking stupid questions, but as I mentioned before, I
>am new to this stuff and a little scared of the moment when a user uses
>my app for more than 30 minutes :-)
First of all, don't do memory management with any other tool than e.g.
ObjectAlloc. Mac OS X virtual memory will mislead you, because it retains
memory you are not actually using, so think only in terms of actual objects
/ leaks. That said, virtual memory itself can take a little management. The
problem might be that virtual memory doesn't let go of disk areas that you
read. This is very noticeable with big disk areas (i.e. images). I had this
problem with an image-processing app until Michael Rothwell put me onto
fcntl and F_NOCACHE. This solved things instantly. Check the archives. m.
PS Also memory management with images is tricky in general because of
caching. I do a lot of recaching (perhaps unnecessarily).
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden