简体   繁体   中英

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. 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? There is usually about 1GB difference...Why?

Thank you.

JVM memory usage can be explained by this image:

JVM内存使用情况

As you can see, it's not just -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. 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.

If you need the details, use some profiler like JConsole or YourKit.

It is worth remembering that Java allocates the maximum heap size on startup and this shows in the virtual memory size. (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.

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. In task manager it says the size is 173 MB private and 196 MB total.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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