On Jan 14, 2009, at 2:31 PM, Tobias Zimmerman wrote:
I have searched for an answer to this question, including in Amit Singh's
book, but have not found the answer (at least, not in a form that I
recognize it).
I have a fairly simple Cocoa app that creates an NSStatusItem with a small
menu.  It is compiled using Garbage Collection and in 64bit mode (it
identifies in the Activity Monitor as "Intel(64 bit)".

In non-debug mode it basically just sits there. The active memory usage is quite reasonable -- about 4.5 to 7.5MB of RPRVT, 10MB RSIZE and 23-30MB RSHRD. However, the VSIZE is 8.36GB ("giga", with a "G"). Compiling in 32bit mode drops VSIZE to 475MB, which is still an awful lot for such a
small app.

I know there are people who will say "VSIZE doesn't matter if there is no paging", but if I ever sought to distribute my app people will not want to
install a statusitem that looks like a memory hog.

My question is two-fold: (1) How does the OS determine how much to allocate to VSIZE? and (2) is there something I am doing wrong in my app (likely)
that is causing the out-sized allocation?

Nope -- you aren't doing anything wrong.

VSIZE does not actually indicate the amount of memory allocated, but not necessarily used or paged out, for the application.

A more accurate description is that VSIZE indicates the amount of address space the application has reserved.

Under 64 bit, the garbage collector reserves 8GB of address space to ensure that the Auto Zone -- the allocation zone from which the collector allocates all objects -- remains contiguous up to 8GB of GC'd memory usage. As allocation requests are fulfilled, chunks of the address space are doled out to the program and utilized.

Note that reserving address space comes nearly for free (there is a bit of administrative metadata). It is touching the memory -- writing data into it -- that is costly.

The absolute VSIZE of your application isn't terribly useful. The change over time is, though. If the VSIZE is increasing relatively steadily over time *and* you don't know exactly why (there are legitimate reasons, especially under 64 bit), then it likely indicates that there is a memory leak in the form of, say, mapped files.

In general, the RSIZE and RPRVT of your application are more immediately interesting.

b.bum

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to