Skip to content
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 in multipart uploads #3259

Open
jerseyrobot opened this issue Oct 11, 2015 · 9 comments
Open

memory leak in multipart uploads #3259

jerseyrobot opened this issue Oct 11, 2015 · 9 comments

Comments

@jerseyrobot
Copy link
Contributor

Requests with multipart uploads create temp files (MIMExxx.tmp) which are marked for deletion using the JVM hook deleteOnExit. For long-running server processes, this is not appropriate since it leads to a memory leak (tracking of an ever-increasing number of references in a LinkedHashSet in java.io.DeleteOnExitHook).

See related mimepull issue: https://java.net/jira/browse/MIMEPULL-13

Affected Versions

[2.21]

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
Reported by phraktle2

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
phraktle2 said:
Any plans on fixing this? This affects long running server-apps, resulting in OOM.

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
phraktle2 said:
This is still a problem.

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JERSEY-2987

@jerseyrobot
Copy link
Contributor Author

@gopi-gith
Copy link

gopi-gith commented Jul 6, 2018

Due to this bug, we are forced to move away from using MultiPart. We refactored our APIs to use non-multipart requests. Is there a way to upvote this bug?

@essobedo
Copy link

essobedo commented Apr 21, 2020

FYI, this bug seems to be fixed thanks to eclipse-ee4j/metro-mimepull#13 that is included in mimepull 1.9.13 and that is now the version used in the master branch of jersey thanks to this commit 950ce6c#diff-600376dffeb79835ede4a0b285078036
However so far there is no release of Jersey that includes this upgrade so If you need a fix, you will have to force the version of mimepull to 1.9.13 in your project which I did and it seems to work well.

@averigin
Copy link

It looks like mimepull was updated to 1.9.13 in #4425 which was released as part of v2.31.

However, it still seems that multipart requests with files end up generating delete-on-exit hooks. FormDataParamValueParamProvider$FileProvider still calls Utils.createTempFile(), which calls File.deleteOnExit().

@averigin
Copy link

averigin commented Dec 6, 2021

I finally had time to revisit this.

In my endpoint definition, I switched from using a File to an InputStream. From what I can tell in FormDataParamValueParamProvider.java, this generates a FormDataParamValueProvider instead of a FileProvider, so it bypasses the Utils.createTempFile() call. Thus, my endpoint no longer generates delete-on-exit hooks for every request.

I still think this is a work-around and not a proper solution, but I'm posting it in the hopes that it helps someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants