Java application memory size

后端 未结 2 528
轮回少年
轮回少年 2021-01-06 15:52

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

相关标签:
2条回答
  • 2021-01-06 16:28

    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.

    0 讨论(0)
  • 2021-01-06 16:31

    JVM memory usage can be explained by this image:

    JVM Memory Usage

    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.

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