0

I'd like to be able to set a heap size programmatically in Java, and since that doesn't appear to be possible to do at runtime, I'm guessing I'll have to start a new JVM process instead.

Is there a well-defined way to do so, or will I have to hack together something horrible and unmaintainable that will never work on VM implementations that I haven't foreseen? There doesn't seem to be anything in javax.tools, but perhaps I've missed it in some other package.

Dolda2000
  • 25,216
  • 4
  • 51
  • 92
  • The accepted answer is portable ... more or less ... and probably as good as you will get. – Stephen C May 09 '15 at 00:58
  • @StephenC: Thanks; I tried searching for such questions, but they seem to have eluded me. That's precisely the kind of answer I was hoping to not get, but if that question hasn't received a better one, then I guess it is what it is and I'll just have to accept my fate. – Dolda2000 May 09 '15 at 01:00
  • 1
    Better as in "more accurate" or "more to your liking"? Either way, you are free to post a bonus on the Question (that I linked to) asking for "better" answers. You have lots of reputation points ... and that's partly what they are there for. But just asking the same thing in a different Question is just asking for your Question to be closed ... as a duplicate. – Stephen C May 09 '15 at 02:19
  • @StephenC: Sorry, I didn't mean to sound demeaning to the question or its answer, and I accept that it probably is as good as it gets. What I meant by "better" was "less susceptible to portability issues" or just generally "more well-defined", as I hold no great hope that the solution in the linked answer has any great chance of working on eg. non-Hotspot JVMs. – Dolda2000 May 09 '15 at 05:16
  • In other words, what I was hoping for was something akin to, say, `javax.tools.ToolProvider.getJavaRuntime()`, which could be common among compliant implementations. – Dolda2000 May 09 '15 at 05:25

0 Answers0