Hi,
A few years ago at JavaOne (it was maybe 2003?) I was on stage during the HS BOF. A developer asked "why do I have to explicitly set my heap size? can't you just look at how much memory my machine has and just take 90% of it?" (which is what you're asking...).
At that moment (and in answer to your question) another developer gets up and says "don't do this! I run 30 VMs on my machine, if you do this my machine will grind down to a halt."
To elaborate a bit more: the HotSpot JVM runs on many different platforms and in many different environments. And we feel that, if we simply take over a machine's memory, in many environments this would be the wrong thing to do.
Hope this clarifies our approach a bit more,
Tony
> Hi,
>
> A few years ago at JavaOne (it was maybe 2003?) I was
> on stage during the HS BOF. A developer asked "why
> do I have to explicitly set my heap size? can't you
> just look at how much memory my machine has and just
> take 90% of it?" (which is what you're
> asking...).
>
Of course there are several alternatives which would meet the needs of both.
For example a command line option that takes a percentage and only attempts to acquire that much memory.
Or a command line option that acquires all the memory it can.
Or even a command line option that does nothing but determine how much memory could be allocated and just prints that and exits the VM.
> Of course there are several alternatives which would
> meet the needs of both.
Of course!
> For example a command line option that takes a
> percentage and only attempts to acquire that much
> memory.
Well, this might not always be helpful, given that your app might get an OOM or not depending on how much memory the machine you run it on has. Having said that, we do something like that and our ergonomic framework uses a more generous heap size when detecting a server-style machine.
> Or a command line option that acquires all the memory
> it can.
Again, as I said, we're worried about users running with that parameter on shared machines.
> Or even a command line option that does nothing but
> determine how much memory could be allocated and just
> prints that and exits the VM.
You can probably work that out very easily using a quick shell script?
Tony
>
> > Or a command line option that acquires all the
> memory
> > it can.
>
> Again, as I said, we're worried about users running
> with that parameter on shared machines.
>
Errr....then your argument is wrong.
Your previous suggestion along those lines was why a VM couldn't automatically grab the space, at least that is how I read it.
This suggestion is that it only goes when a specific parameter is used.
The fact that other apps are running doesn't impact how much memory one application can request or even acquire. You can run 20 VMs on a windows box all of which grab 1.4 gig. The performance might not be what you want but then the performance might not be what you want with each of them only getting 64 meg either. Tuning that sort of set up is outside the domain space of the VM. And it is something that would have to be done regardless of any possible solution suggested.
> > Or even a command line option that does nothing but
> > determine how much memory could be allocated and just
> > prints that and exits the VM.
>
> You can probably work that out very easily using a
> quick shell script?
Which, as I previously suggested, is the only possibility with the current VM. Printing it out would require less start up time.
> Hi,
>
> A few years ago at JavaOne (it was maybe 2003?) I was
> on stage during the HS BOF. A developer asked "why
> do I have to explicitly set my heap size? can't you
> just look at how much memory my machine has and just
> take 90% of it?" (which is what you're
> asking...).
>
> At that moment (and in answer to your question)
> another developer gets up and says "don't do this!
> I run 30 VMs on my machine, if you do this my machine
> will grind down to a halt."
>
> To elaborate a bit more: the HotSpot JVM runs on many
> different platforms and in many different
> environments. And we feel that, if we simply take
> over a machine's memory, in many environments this
> would be the wrong thing to do.
>
> Hope this clarifies our approach a bit more,
>
> Tony
Sorry for late reply, I can understand that, thanks. However, for my case, I am pretty sure that my client machine will run that single JVM, (in fact, even more, he will run that single application at that computer) . Is it possible for future version of java runtime have an argument like -useallavailable memory, and user use it as his own risk?