Re: What determines VSIZE allocation?
Re: What determines VSIZE allocation?
- Subject: Re: What determines VSIZE allocation?
- From: Andrew Farmer <email@hidden>
- Date: Wed, 14 Jan 2009 19:41:25 -0800
On 14 Jan 09, at 14:31, 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?
The short version:
Ignore the number under the VSIZE column. In fact, turn that column
off. It has no practical meaning whatsoever.
The long version:
VSIZE is the total amount of address space that's mapped for your
application. This includes things like libraries and shared memory, so
it doesn't really correlate directly with *real* memory usage (which
is tracked much more accurately by RSIZE). Beyond that, I understand
that garbage collection also uses virtual memory in various clever
ways. This is most noticeable under 64-bit builds, but I think it does
similar things (albeit on a more limited scale) under 32-bit builds.
If you're curious what all the virtual address space is being used for
within an application, play around with the vmmap and vmmap64
utilities. But don't try to minimize address space usage unless you're
actually low on it (in 32-bit apps).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden