0

I have a java process which I startup and let run for several days. The logs for this process looked fine up until the very end of the process's lifetime where I see the following two lines, and then nothing after it.

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

There is supposed to be some shutdown logic which is executed when the process ends, but these two log lines are all I see.

What is the cause of this std::bad_alloc error? I've seen several other posts regarding this error but they are all from C++ programmers, whereas I am using Java, not C++. Does this indicate a bug in the JVM, or is it a consequence of some JVM related error such as an OutOfMemoryError?

almel
  • 7,178
  • 13
  • 45
  • 58

1 Answers1

2

You've run out of native memory (which is distinct from the java heap). To fix this, you'd need to understand which code of yours (or jars on your classpath) are using C++ under the hood and making sure that things are being gc'd in a timely fashion.

For example, if you weren't calling close you'd possibly run into the same issue: https://docs.oracle.com/javase/7/docs/api/java/util/zip/GZIPInputStream.html#close()

amos
  • 5,092
  • 4
  • 34
  • 43