JVM常见问题有哪些
这篇文章主要介绍JVM常见问题有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
创新互联公司专业为企业提供八步网站建设、八步做网站、八步网站设计、八步网站制作等企业网站建设、网页设计与制作、八步企业网站模板建站服务,十载八步做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
多个 java 程序设置内存超过系统内存范围会阻止启动吗?即程序在启动时就占满其内存,还是按需增长? 例如:一台主机,能启动5个默认配置(By default, the JVM will use MaxMemory/4 )的程序吗? 一同事说在一个128G内存的机器上无法启动新的java程序,询问得知此服务器启动过四个java应用,后查看服务器内存占满包括swap。
JVM 在什么时候会释放内存给操作系统?或者什么时候 JVM 进程内存使用量会降低 理论上 JVM “不会(或者说极为严苛)” 释放不使用的内存给 操作系统, 监控发现 JVM 进程内存使用量会降低,释放的是哪块内存 https://www.geekyhacker.com/2019/01/04/jvm-does-not-release-memory/ https://stackoverflow.com/questions/6785754/jvm-process-vs-jvm-heap-memory-usage
如果主机内存资源紧张,会有抑制JVM虚拟机内存增长的机制吗? 线上同一个服务有多个实例,在内存资源紧张的主机上的实例占用的内存要低于其他实例
java 内存与 Linux 显示进程使用内存的关系
jstat https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html Native Memory Tracking https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html jmx command tool emjmxcli
java 内存与 运行在 Docker 中 Linux 显示进程使用内存,Docker contener 使用内存的关系
java 内存与 运行在 kubernetes 中 Linux 显示进程使用内存,Docker contener 使用内存, POD 使用内存的关系
cat << \EOF > JmxTest.java import javax.management.*; import javax.management.remote.JMXServiceURL; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXConnector; import java.lang.management.RuntimeMXBean; import static java.lang.management.ManagementFactory.*; import java.net.Socket; import java.net.InetSocketAddress; import java.io.File; import java.io.IOException; import java.util.Properties; // Sun specific import com.sun.tools.attach.VirtualMachine; // Sun implementation specific import sun.management.ConnectorAddressLink; public class JmxTest { /* * Starts the management agent in the target VM */ private static void startManagementAgent(String pid) throws IOException { /* * JAR file normally in ${java.home}/jre/lib but may be in ${java.home}/lib * with development/non-images builds */ String home = System.getProperty("java.home"); String agent = home + File.separator + "jre" + File.separator + "lib" + File.separator + "management-agent.jar"; File f = new File(agent); if (!f.exists()) { agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; f = new File(agent); if (!f.exists()) { throw new RuntimeException("management-agent.jar missing"); } } agent = f.getCanonicalPath(); System.out.println("Loading " + agent + " into target VM ..."); try { VirtualMachine.attach(pid).loadAgent(agent); } catch (Exception x) { throw new IOException(x.getMessage()); } } private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); ObjectName directName = ObjectName.getInstance("java.nio:type=BufferPool,name=direct"); MBeanInfo mbInfo = server.getMBeanInfo(directName) ; for(MBeanAttributeInfo i : mbInfo.getAttributes()) { System.out .println(i.getName() + ":" + server.getAttribute(directName , i.getName())); } // RuntimeMXBean rt = newPlatformMXBeanProxy(server, // RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); // System.out.println(rt.getName()); // close the connection c.close(); } private final static String LOCAL_CONNECTOR_ADDRESS_PROP = "com.sun.management.jmxremote.localConnectorAddress"; public static void main(String[] args) throws Exception { String pid = "1"; VirtualMachine vm = VirtualMachine.attach(pid); String agentPropLocalConnectorAddress = (String) vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP); int vmid = Integer.parseInt(pid); String jvmstatLocalConnectorAddress = ConnectorAddressLink.importFrom(vmid); if (agentPropLocalConnectorAddress == null && jvmstatLocalConnectorAddress == null) { // No JMX Connector address so attach to VM, and load // management-agent.jar startManagementAgent(pid); agentPropLocalConnectorAddress = (String) vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP); jvmstatLocalConnectorAddress = ConnectorAddressLink.importFrom(vmid); } // Test address obtained from agent properties System.out.println("Testing the connector address from agent properties"); connect(pid, agentPropLocalConnectorAddress); // Test address obtained from jvmstat buffer // System.out.println("Testing the connector address from jvmstat buffer"); // connect(pid, jvmstatLocalConnectorAddress); // // Shutdown application // int port = Integer.parseInt(args[1]); // System.out.println("Shutdown process via TCP port: " + port); // Socket s = new Socket(); // s.connect(new InetSocketAddress(port)); // s.close(); } } EOF javac -Djava.ext.dirs=/usr/java/jdk1.8.0_121/lib JmxTest.java java -Djava.ext.dirs=/usr/java/jdk1.8.0_121/lib JmxTest
以上是“JVM常见问题有哪些”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
网页题目:JVM常见问题有哪些
本文URL:http://scjbc.cn/article/gpeihj.html