简体   繁体   English

Java应用程序内存大小

[英]Java application memory size

While either IntelliJ or Eclipse are running, I can see how much heap they are using from inside the application from the progress bar at the bottom.. it always indicates a sub 512 MB value which the max size allocated on startup. 当IntelliJ或Eclipse正在运行时,我可以从底部的进度条看到它们在应用程序内部使用了多少堆...它总是指示一个512 MB的子值,它是启动时分配的最大大小。 Now in many cases, if I look from the OS (Linux) it says that the app is using about 1300 MB, I understand that the libraries, stack, memory mapped files, ... are not in the heap... But why is the difference that big? 现在在很多情况下,如果我从操作系统(Linux)看,它说该应用程序使用大约1300 MB,我理解库,堆栈,内存映射文件,...不在堆...但为什么差别那么大? There is usually about 1GB difference...Why? 通常有大约1GB的差异......为什么?

Thank you. 谢谢。

JVM memory usage can be explained by this image: 可以通过此图像解释JVM内存使用情况:

JVM内存使用情况

As you can see, it's not just -Xmx . 如您所见,它不仅仅是-Xmx Total process memory would also include the -XX:PermSize , stack size of all the threads, JVM memory used by the JIT and other internals. 总进程内存还包括-XX:PermSize ,所有线程的堆栈大小,JIT和其他内部使用的JVM内存。 Don't forget about the memory mapped files which are also included in the process memory. 不要忘记也包含在进程内存中的内存映射文件。 IntelliJ IDEA uses memory mapped files for caches, so it can add several hundreds megabytes. IntelliJ IDEA将内存映射文件用于缓存,因此它可以添加几百兆字节。

If you need the details, use some profiler like JConsole or YourKit. 如果您需要详细信息,请使用JConsole或YourKit等分析器。

It is worth remembering that Java allocates the maximum heap size on startup and this shows in the virtual memory size. 值得记住的是,Java在启动时分配了最大堆大小,这显示在虚拟内存大小中。 (This is by default proportional to the amount of memory you have) This can be much larger than the actual main memory used. (默认情况下,这与您拥有的内存量成比例)这可能比实际使用的主内存大得多。

I suspect you are looking at this virtual memory rather than the resident memory. 我怀疑你正在看这个虚拟内存而不是常驻内存。

If you use pmap on linux you can see all the memory mapped regions and their sizes. 如果你在linux上使用pmap,你可以看到所有内存映射区域及其大小。

If a restart IntelliJ with an open project on Windows, it says its using 35 MB of about 100 MB used with a 494 M maximum. 如果在Windows上使用打开的项目重新启动IntelliJ,则表示它使用35 MB的大约100 MB,最大使用494 M. In task manager it says the size is 173 MB private and 196 MB total. 在任务管理器中,它说大小为173 MB私有,总共196 MB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM