On Aug 3, 2007, at 3:57 PM, Joel Uckelman wrote: > Thus spake Thomas Russ: >> >> On Aug 3, 2007, at 12:51 PM, Justin Morgan wrote: >> >>> >>> My question is, why can't Java allocate memory as needed? It seems >>> to put itself in a box which reduces the flexibility of a multi- >>> purpose language. >> >> My guess is that this is part of the legacy of the sandboxing to make >> web-launched applications unable to gobble up your entire memory. It >> stops a certain class of denial of service attacks and can stop >> runaway or malicious programs from exhausting your available memory. > > That's precisely the reason. I've often wished that it were > possible to > tell the Java virtual machine to use however much memory it needs, but > that's not been in the cards, unfortunately.
I suppose that one can, effectively, do this by careful specification of the minimum and maximum sizes. I'm not sure what the limits of the JVM are for memory, but something like a minimum of 32 or 64 MB and a maximum of 2 or 4 GB should do it. 4GB is the theoretical limit on 32-bit systems, and usually you can't actually get all of that. Empirically, on my current 32-bit Mac, I can use up to a bit over 2GB for the heap.
