-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak while scanning annotations #575
Comments
This would be a duplicate of Issue #231 |
We don't need to undeploy the app, just deploying it causes the issue. |
I'm still talking to Oracle about this jvm bug. Interestingly, it doesn't seem to be reproduceable with jdk9. Are you able to test with jdk9 and report results back here? |
I just tried with JDK9 and the bug is still there. |
Here's a link to the java bugs database issue: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8156014 I'd like to be able to comment on it, but I can't seem to find a link to allow me to do that. The comments I'd like to add are:
I've tried some workarounds for jdk8: it seems the ServiceLoader impl uses the jarurlconnection caching, so it may be of some benefit to try to disable url caching (although not sure of the effects on performance). Try creating an xml file (eg called "caches.xml") with the following contents: <Configure id="Server" class="org.eclipse.jetty.server.Server">
<Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set>
<New class="java.io.File">
<Arg>
<SystemProperty name="java.io.tmpdir"/>
</Arg>
<Call name="toURI">
<Call id="url" name="toURL">
<Call name="openConnection">
<Set name="defaultUseCaches">false</Set>
</Call>
</Call>
</Call>
</New>
</Configure> Then put that on the command line eg java -jar ../start.jar caches.xml |
I got the same problem. by gperftools , I found this kind of memory leak. |
As Oracle closed this bug, they will not be backporting any fixes for it to jdk8 for public release. It appears that further updates to jdk8 will be for Oracle customers only, therefore Oracle customers need to ask Oracle to take this any further. See: I'm going to close this issue, as there's nothing that I can see that Jetty can do about it at this time, other than recommend updating to a newer jdk version. |
While scanning classes for annotations, jars are opened as zip files but they are not closed properly which caused the memory leak.
memory_leak_example.zip
We were investigating a Jetty application that used much more memory than it was supposed to do (near a Gb more than the max heap size plus the max metaspace size). We found out that the extra memory was Native memory, being allocated using malloc via some library (we don't have native code in our app). Then we used jemalloc ( http://www.canonware.com/jemalloc/) to find out which class was doing this allocation and we found out that it was java.util.zip.Inflater. Via jstack we were able to find calls to the library and the main caller was Jetty, while in the process of looking for annotations. We disable annotations for the application and the memory usage went back to normal.
We looked at the Jetty code for the version we are using (9.2) and definitly the bug is there ( scanClass(handlers, jar, clazz.getInputStream()) in line 956 of AnnotationParser.java, that input stream is never closed). What is very strange is that while code in version 9.3 seems to be fixed (it uses try-with-resources to close the input streams) the leak seems to still be there: we did the same tests than in 9.2, jemalloc reports the missing memory and the application with annotations uses a lot more memory than without.
We attach a project that shows the same behaviour than our application. If started with annotations it mallocs much more memory and it can be traced to annotations search.
The text was updated successfully, but these errors were encountered: