-
Notifications
You must be signed in to change notification settings - Fork 16
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
LoadingMessageSourceProvider can cause OOM errors #1
Comments
Yep, I do have this problem. It occurs in our Vert.x environment. |
OK, I admit that this can be a problem; now there is the lifecycle to consider. If this is the JVM itself then when it shuts down the problem is not there. If this is a dynamically loaded jar, such as in a webapp, then a mechanism should exist that shuts down all generated |
It occurred in the vertx-json-schema-validator, which uses the |
@alexvetter how is this related to this package then? The default loading configuration uses statically initialized message bundles; if this is not the case it means that you change the message bundle to a loading one. Can you show some example code? |
The
|
The fact that
|
Could the hard-coded ExecutorService be set up to release threads after a time, and spin them up again as required? e.g. in LoadingMessageSourceProvider, change:
to
This is hitting a GUI app I work on. Even without the OSGI scenario, For reasons (that I won't go into) we set the default per thread stack size to 4MB, and 36MB is a lot of extra RAM to consume when it is seemingly unused most of the time. |
LoadingMessageSourceProvider creates a thread factory which creates daemon threads with no way of shutting them down.
The comments explicitly states:
/*
* Use daemon threads. We don't give control to the user about the
* ExecutorService, and we don't have a reliable way to shut it down (a JVM
* shutdown hook does not get involved on a webapp shutdown, so we cannot
* use that...).
*/
Unfortunately, this can cause OutOfMemory errors, especially in an OSGi environment, when these threads stay alive across bundle restarts. This provider should expose a way to safely shutdown / manage the lifecycle of the executor service threads.
Also, json-schema-validator which consumes this library should also expose a way to shut this down.
The text was updated successfully, but these errors were encountered: