6

I have a single Java application running on eJDK 1.8.201. I observed that the system reported RSS usage of the java process keeps increasing, it will reach over than 90% of the physical memory that is 512M, and my code will reboot the system. On the other hand, the usedMemory() I printed out periodically from the code shows that it always fluctuates within a limited range no more than 37% of the physical memory (means <= 190M). From my understanding, that means the JVM was not returning it's free memory to the OS. Is this understanding correct? I've set the -Xmx=256M -Xms=256M, so I think the -Xmx options was not working.

Do you have any idea about what was happening and how to fix the issue?

The system is an embedded Linux on an ARMv7 board.

Woody Wu
  • 358
  • 3
  • 13
  • 2
    Seems the growing memory consumption is not the heap memory. – Holger Jun 15 '19 at 09:53
  • If it's not the heap, what's that? Thanks – Woody Wu Jun 15 '19 at 10:16
  • 2
    There are different possibilities, stack, direct buffers, code cache, just memory allocated by native code, etc. – Holger Jun 15 '19 at 10:22
  • most likely it's consumed by off-heap memory https://www.waitingforcode.com/off-heap/on-heap-off-heap-storage/read You should review your dependencies and see to their off-heap memory usage – Nestor Sokil Jun 15 '19 at 10:38
  • I know in jdk there are some tools can dump heap, such as jhat, jcmd. Does some know is there any tool in ejdk (embedded JDK from oracle) can get me dump and analyze where the increased memory are used? Thanks. – Woody Wu Jun 15 '19 at 12:17
  • A key suspicious point: If the increasing memory is not heap. Why the runtime.freeMemory() getting increase in the same speed of runtime.totalMemory()? JVM will count off-heap as free? – Woody Wu Jun 15 '19 at 13:07
  • Sorry, maybe I was wrong, the freeMemory() should not being increasing. So, it's still possible the off-heap memory was leaking. Please someone give me an advice that how to analyze off-heap memory for eJDK or eJRE environment. Thanks in advance. – Woody Wu Jun 15 '19 at 17:11
  • In Java 8 the `PermGen` was replaced with`Metaspace`. I had an issue previously were the loading of dynamic Groovy classes at runtime was causing the `Metaspace` to continually grow. There is no min `Metaspace` set by default. This would be worth looking in to. – Garreth Golding Feb 04 '20 at 12:12
  • Does this answer your question? [Is there a way to lower Java heap when not in use?](https://stackoverflow.com/questions/4952568/is-there-a-way-to-lower-java-heap-when-not-in-use) – Michael Piefel Dec 31 '20 at 18:31

1 Answers1

0

The -Xmx=512M and -Xms=512M are invalid flags. They should be changed to -Xmx512M and -Xmx512M.

David
  • 98
  • 8