Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: maximum heap size



Alan Snyder <email@hidden> wrote:

>My experience so far is that I sometimes need to set the maximum heap size
>if my program is using large data structures. If that's correct, then it
>follows that for some applications the end user might need to set the
>maximum heap size, if the application data usage depends upon the user
>data. (Consider an image processing application, for example.) If so,
>then is there some nice way provided by OS X for an end user to set this
>parameter, such as via the Finder Get Info interface?

There's no way to do this on Mac OS X.

Nor on any other platform, now that I think about it.

In a Mac OS X app-bundle, you could just set the max-heap fairly high and
be done with it, since the virtual-memory system does not allot swap-space
until the VM page is actually used. I don't know how other OSes set aside
swap-space for large virtual-memory allotments, so this tactic may not work
on other platforms.


There's also a way to make it somewhat auto-adjusting, if your users can
accept an app relaunch in-between. You'd have to implement this yourself,
but here's the basic strategy...

To avoid thrashing the HD with swapping, you'd want to enforce a
machine-specific ceiling, which the auto-adjuster would never exceed
without manual confirmation. A simple heuristic is the amount of physical
RAM in the machine. You can determine the amount of physical RAM using
this command:
sysctl hw.physmem

Or use the amount of swappable (non-kernel) RAM:
sysctl hw.usermem

You'd Runtime.exec() the command and parse the result, then use that number
to modify the Info.plist or MRJApp.properties of the bundled-app. This
would require write-access to the app's internal structure, which is
potentially a security exposure. So you might want to have the
auto-adjuster be a separate program with restricted execution privileges
(not public-execute).

See 'man sysctl' for a list of available command parameters. Also see 'man
3 sysctl' for detailed programmer info on what the names mean. Try 'sysctl
hw' for a list of available hardware values. Try 'sysctl -a' for a list of
all available parameters and their current values.

The 'sysctl' command is a Unix command, so maybe this would work on Linux
or Solaris, but almost certainly not on Windows.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.