2

What does java.lang.OutOfMemoryError: null imply.

I.E why is the reason stated as null. I saw this exception when I was trying to work with sun.misc.unsafe. Now I know we shouldn't be using this library. But aside from that What I would like to know is how to understand when this exception is thrown. what are the reasons for which it could be thrown? In my case, I believe it was probably triggered to allocate a large memory size.

What other scenarios would this come from??

Vipin Menon
  • 2,892
  • 4
  • 20
  • 35
  • Possible duplicate of [Error java.lang.OutOfMemoryError: GC overhead limit exceeded](https://stackoverflow.com/questions/1393486/error-java-lang-outofmemoryerror-gc-overhead-limit-exceeded) – Dark Knight Nov 19 '18 at 06:29
  • @Vipin This [https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html] would help you out! – Abhinav Nov 19 '18 at 06:30
  • Possible duplicate of [How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size)](https://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap) – Abhinav Nov 19 '18 at 06:31
  • @Abhinav..The link gives a 404. Also, I'm looking for a specific type "NULL" – Vipin Menon Nov 19 '18 at 06:45
  • The null value is not a "type" it's the detailed error message and those are not defined by the language specification. An OOME was created with a null message and processed by defective code. – Torben Nov 19 '18 at 07:07
  • 1
    This is where you need to check the stack trace to see the likely cause. If there is no stack trace, you need to check if thus has happened many times and find the first time. – Peter Lawrey Nov 19 '18 at 07:29
  • And if you want someone to track this down without a stacktrace, you need to tell us a lot more. Like what version of Java you were using, what vendor, what method was called to trigger the exception, etcetera. – Stephen C Nov 19 '18 at 08:06
  • FWIW, one scenario is calling `throw new OutOfMemoryError(null)` in user code. – Stephen C Nov 19 '18 at 08:07

1 Answers1

1

This means that the java.lang.OutOfMemoryError was thrown without an error message. Other answerers are correct that there can be different reasons, and you will need to check the stack trace. In my recent case, it was due to attempting to allocate a String Buffer larger than the java limit in JDK 11, where this error was thrown without a message: https://bugs.openjdk.java.net/browse/JDK-8230744 (fixed in jdk 15).