Currently I am trying to resolve a Java memory issue: My Java application keeps using more and more memory and eventually it gets killed by the Linux OOM killer.
There is probably a Native Memory leak, because after inspection of the JVM with VisualVM both metaspace and the heap look OK.
Using the top command I can see that the memory used by the JVM keeps on increasing.
The first graphic in this article:
Example #1
Is a perfect match of what I am seeing in my own application.
So I tried using JeMalloc to find the leak as described in various articles. Here I run into a problem: When using the jeprof command and later the top command in jeprof itself, it does show the functions that use the most memory, but these are in hexadecimal addresses, so I must be missing some symbols. But I do not know which packages I need for that, that is unknown to me.
I already found this link: Link #1
And installed this package: debuginfo-install java-1.8.0-openjdk
I tried to work through simple steps first:
Get JeMalloc to work with a simple application, such as w. Next get it to work with java -version. So far so good, I can also get PDF's from JeMalloc with a perfect overview.
Next get it to work with java -jar simpletest.jar << Here I am missing symbols For example, if I do not close a GZipInputStream here, that does not show up in the JeMalloc results.
Next get it to work with java -jar myapplication.jar << Here I am missing symbols as well.
So my question is basically: What packages do I need in order to get JeMalloc to display all symbol-names to debug applications such as:
public void test1() {
InputStream fileInputStream = null;
GZipInputStream gzipInputStream = null;
try {
fileInputStream = new FileInputStream("test.zip");
gzipInputStream = new GZIPInputStream(fileInputStream);
int data = gzipInputStream.read();
while (data != -1) {
// do something with data
data = gzipInputStream.read();
}
} catch (Exception ex) {
} finally {
// Disabled to see whether JeMalloc can detect the leak
/*try {
if (gzipInputStream != null) {
gzipInputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
gzipInputStream = null;
fileInputStream = null;
} catch (IOException e) {
e.printStackTrace();
}*/
}
}
Using the following software:
- Linux CentOS 7
- JeMalloc
- OpenJDK
Articles found:
Article #1
Article #2
Article #3
Article #4