<legend id='cYxJ3'><style id='cYxJ3'><dir id='cYxJ3'><q id='cYxJ3'></q></dir></style></legend>
    <bdo id='cYxJ3'></bdo><ul id='cYxJ3'></ul>
  • <i id='cYxJ3'><tr id='cYxJ3'><dt id='cYxJ3'><q id='cYxJ3'><span id='cYxJ3'><b id='cYxJ3'><form id='cYxJ3'><ins id='cYxJ3'></ins><ul id='cYxJ3'></ul><sub id='cYxJ3'></sub></form><legend id='cYxJ3'></legend><bdo id='cYxJ3'><pre id='cYxJ3'><center id='cYxJ3'></center></pre></bdo></b><th id='cYxJ3'></th></span></q></dt></tr></i><div id='cYxJ3'><tfoot id='cYxJ3'></tfoot><dl id='cYxJ3'><fieldset id='cYxJ3'></fieldset></dl></div>

    1. <tfoot id='cYxJ3'></tfoot>

      <small id='cYxJ3'></small><noframes id='cYxJ3'>

        Java 似乎忽略了 -Xms 和 -Xmx 选项

        时间:2023-08-23
          1. <small id='7ChG5'></small><noframes id='7ChG5'>

            <legend id='7ChG5'><style id='7ChG5'><dir id='7ChG5'><q id='7ChG5'></q></dir></style></legend>
              <i id='7ChG5'><tr id='7ChG5'><dt id='7ChG5'><q id='7ChG5'><span id='7ChG5'><b id='7ChG5'><form id='7ChG5'><ins id='7ChG5'></ins><ul id='7ChG5'></ul><sub id='7ChG5'></sub></form><legend id='7ChG5'></legend><bdo id='7ChG5'><pre id='7ChG5'><center id='7ChG5'></center></pre></bdo></b><th id='7ChG5'></th></span></q></dt></tr></i><div id='7ChG5'><tfoot id='7ChG5'></tfoot><dl id='7ChG5'><fieldset id='7ChG5'></fieldset></dl></div>

                <tbody id='7ChG5'></tbody>
                <bdo id='7ChG5'></bdo><ul id='7ChG5'></ul>
                <tfoot id='7ChG5'></tfoot>

                  本文介绍了Java 似乎忽略了 -Xms 和 -Xmx 选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在我的 VPS 上运行一个用 java 编写的非常简单的机器人.我想将 jvm 内存限制为 10MB(我怀疑它是否需要更多).

                  I'd like to run a very simple bot written in java on my VPS. I want to limit jvm memory to let's say 10MB (I doubt it would need any more).

                  我正在使用以下命令运行机器人:

                  I'm running the bot with the following command:

                  java -Xms5M -Xmx10M -server -jarIrcBot.jar "/home/jbot"

                  java -Xms5M -Xmx10M -server -jar IrcBot.jar "/home/jbot"

                  但是 top 显示为 java 保留的实际内存是 144m (或者我在这里解释错了吗?).

                  But top shows that actual memory reserved for java is 144m (or am I interpreting things wrong here?).

                  13614 jbot 17 0 144m 16m 6740S 0.0 3.2 0:00.20 java

                  13614 jbot 17 0 144m 16m 6740 S 0.0 3.2 0:00.20 java

                  有什么想法可以在这里出错吗?

                  Any ideas what can be wrong here?

                  Java 版本1.6.0_20"Java(TM) SE 运行时环境(内部版本 1.6.0_20-b02)Java HotSpot(TM) 客户端 VM(内部版本 16.3-b01,混合模式)

                  Java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)

                  顺便说一句.我正在运行 CentOS - 如果重要的话.

                  BTW. I'm running CentOS - if it matters.

                  谢谢您的回答.

                  我真的不能接受其中任何一个,因为事实证明问题出在我选择编写程序的语言上,而不是 JVM 本身.

                  I can't really accept any of them, since it turns out the problem lies within the language i choose to write the program, not the JVM itself.

                  推荐答案

                  -Xmx 指定最大 Java heap 分配(-Xms 指定最小分配).Java 进程有自己的开销(实际的 JVM 等),加上加载的类和 perm gen 空间(通过 -XX:MaxPermSize=128m 设置)也在该值之外.

                  -Xmx specifies the max Java heap allocation (-Xms specifies the min heap allocation). The Java process has its own overhead (the actual JVM etc), plus the loaded classes and the perm gen space (set via -XX:MaxPermSize=128m) sits outside of that value too.

                  将您的堆分配简单地视为 Java 的内部工作空间",而不是整个进程.

                  Think of your heap allocation as simply Java's "internal working space", not the process as a whole.

                  尝试一下,你就会明白我的意思:

                  Try experimenting and you'll see what I mean:

                  java -Xms512m -Xmx1024m ...
                  

                  另外,尝试使用 JConsoleJVisualVM 等工具(两者都随 Sun/Oracle JDK 提供),您将能够看到实际的堆使用情况(以及用于限制大小的设置).

                  Also, try using a tool such as JConsole or JVisualVM (both are shipped with the Sun / Oracle JDK) and you'll be able to see graphical representations of the actual heap usage (and the settings you used to constrain the size).

                  最后,正如@Peter Lawrey 非常正确地指出的那样,常驻内存是这里的关键数字 - 在您的情况下,JVM 仅使用 16 MiB RSS(根据顶部").只要 JVM 的堆没有被推入交换(非 RAM),共享/虚拟分配就不会引起任何问题.同样,正如我在一些评论中所说,还有其他可用的 JVM——Java"完全能够在低资源或嵌入式平台上运行.

                  Finally, as @Peter Lawrey very rightly states, the resident memory is the crucial figure here - in your case the JVM is only using 16 MiB RSS (according to 'top'). The shared / virtual allocation won't cause any issues as long as the JVM's heap isn't pushed into swap (non-RAM). Again, as I've stated in some of the comments, there are other JVM's available - "Java" is quite capable of running on low resource or embedded platforms.

                  这篇关于Java 似乎忽略了 -Xms 和 -Xmx 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Java heap Xms 和 linux free memory 不同 下一篇:java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET

                  相关文章

                    <legend id='zdPC6'><style id='zdPC6'><dir id='zdPC6'><q id='zdPC6'></q></dir></style></legend>
                  1. <small id='zdPC6'></small><noframes id='zdPC6'>

                      <tfoot id='zdPC6'></tfoot>

                    1. <i id='zdPC6'><tr id='zdPC6'><dt id='zdPC6'><q id='zdPC6'><span id='zdPC6'><b id='zdPC6'><form id='zdPC6'><ins id='zdPC6'></ins><ul id='zdPC6'></ul><sub id='zdPC6'></sub></form><legend id='zdPC6'></legend><bdo id='zdPC6'><pre id='zdPC6'><center id='zdPC6'></center></pre></bdo></b><th id='zdPC6'></th></span></q></dt></tr></i><div id='zdPC6'><tfoot id='zdPC6'></tfoot><dl id='zdPC6'><fieldset id='zdPC6'></fieldset></dl></div>
                        <bdo id='zdPC6'></bdo><ul id='zdPC6'></ul>