I have theoretical question about OSGi memory management.
Let’s say we have some OSGi container (Felix for instance), and let’s suppose I created some bundle with memory leak.
And here are some questions that I have:
- Is there any way to limit memory
consumption for this “failure”
bundle? For example if it exceeds
memory limit – OSGi container would
send me an email, uninstall it or
something else? - How does memory consumption in
bundle “A” affect bundle “B”. For
example if “A” causes out of memory error
would it blow up whole OSGi
container?
The complete OSGi framework runs in a single virtual machine. Only that each bundle is loaded by a different classloader. But all bundles share the same heap and if one bundle leaks memory, this affects the whole OSGi based application.
So yes, if an OutOfMemoryError is caused by one bundle, the whole container is “blown up”.
(BTW: if someone drops a bundle into your container that does a
System.exit(), then again the whole container is stopped without a warning – bundles do not live in isolated contexts like some “virtual machines inside a jvm”)