Limit total memory consumption of Java process (in Cloud Foundry)

前端 未结 1 822
耶瑟儿~
耶瑟儿~ 2021-01-26 03:11

Related to these two questions:

  • How to set the maximum memory usage for JVM?
  • What would cause a java process to greatly exceed the Xmx or Xss limit?
相关标签:
1条回答
  • 2021-01-26 03:57

    Unfortunately, there is no way to definitively enforce a memory limit on the JVM. Most of the memory regions are configurable (-Xmx, -Xss, -XX:MaxPermSize, -XX: MaxMetaspaceSize, etc.) but the one you can't control is Native memory. Native memory contains a whole host of things from memory mapped files to native libraries to JNI code. The best you can do is profile your application, find out where the memory growth is occurring, and either solve the growth or give yourself enough breathing room to survive.

    Certainly unsatisfying, but in the end not much different from other languages and runtimes that have no control over their memory footprint.

    0 讨论(0)
提交回复
热议问题