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
Bootstrap page payload remains in ThreadLocal cache managed by JSoup #6464
Comments
Based on my investigation, this isn't a regular memory leak per se. Instead, this is a per-thread cache managed by JSoup that may under specific end up with quite much content. What it means is that memory use doesn't grow without bounds, but instead only based on the number of request-serving threads used by the application server. JSoup caches instances of Vaadin uses JSoup to build the bootstrap html page contents. Since this is the last use of JSoup in a typical Vaadin request, the full bootstrap page will remain in a cached string builder until the next time some JSoup functionality that uses a string builder is run on the same thread. The caching was reimplemented in jhy/jsoup#1059 because of issues similar to this and the fix was included in JSoup version 1.12.1. Vaadin 14 is using version 1.11.3. I haven't done a full test run with the new JSoup version, but at least the basic stuff seems to work and the reported issue can no longer be observed if I update
If we for some reason cannot update Vaadin to use the newer JSoup version, then we could as a workaround add a dummy call to |
@Legioth Leif, you are great person! You conducted a very deep investigation and found the root of the issue. I express my deep gratitude to you. I added the newer JSoup version in |
Operating the software with the new JSoup version for a week. Works well, no OutOfMemory errors anymore. Thanks again for your help! |
Thanks for verifying that the new JSoup version seems to work. I've updated Vaadin to use the new version. We ill most likely not release this update in a maintenance release, but it will instead be included in Vaadin 14.1 which will be released within a couple of months. |
@Legioth Thank you for informing me about your release plans! |
Hello! I got a memory leak. I will describe it below as detailed as possible, and also attach a demo project to reproduce it on your machine.
Vaadin 14.0.4, Spring Boot 2.1.7, Java 11.0.4, Tomcat/Jetty/Undertow, macOS High Sierra + Safari.
Let's take
my-starter-project
as a base.application.properties:
MainView.java:
The above code outputs to browser window 50 lines of 10Kb each, no issues. Now, let's replace the constructor's code.
The above code has an issue: a memory leak -- several objects
org.apache.tomcat.utils.threads.TaskThread
are never destroyed (even after MainView objects count and SpringVaadinSession objects count become 0 due to session expiration). It is not related to servlet container, I tried all three available in Spring Boot: Tomcat, Jetty and Undertow. I attached a screenshot. It contains a string with Push data of AtmospherePushConnection (start with<!doctype html>...
).In constructor I pass a lot of data to user's browser window (a large log file, instead of random string data as in this sample), so this memory leak steals a lot of memory at each page refresh and finally leads to OutOfMemory heap error.
my-starter-project.zip
The text was updated successfully, but these errors were encountered: