0

If I compile and run a program in C++, it does not require me to specify how much memory it may use. It will try allocating as much as it needs, until it can't get more. But for the JVM, I need to tell it before running my program how much memory it should have at most. Why can't JVM also just request more memory from the OS, and only crash when it can't be given that much? What is the advantage of having to set a limit?

  • https://stackoverflow.com/questions/3358328/why-does-the-sun-jvm-have-a-fixed-upper-limit-for-memory-usage-xmx – Amir Afghani Oct 29 '20 at 00:36
  • @ScaryWombat That does make sense, and I see why we may want to set a limit. But it's optional when I execute C++ code, while mandatory for JVM. Why? – Aperonamos Oct 29 '20 at 00:41

0 Answers0