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:
OSGi facilitates creating and managing modular Java components (called bundles) that can be deployed in a container. As a developer, you use the OSGi specification and tools to create one or more bundles. OSGi defines the lifecycle for these bundles. It also hosts them and supports their interactions in a container.
Simply said, OSGi is a dynamic module system for Java. It defines means to install, uninstall, update, start and stop modules. Those modules are called bundles, but are, in their simplest form, actually Java jar files with a special Manifest.
How does OSGi work? OSGi is a set of specifications that define a dynamic component system for Java. These specifications allow for a development model in which an application is composed of several components, and then packed into bundles. These components communicate locally and through the network via services.
OSGi defines a dynamic module system for Java™. The OSGi service platform has a layered architecture, and is designed to run on various standard Java profiles. OSGi Applications deployed to WebSphere® Application Server run on an Enterprise Java profile that is provided as part of the server runtime environment.
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")
You may also want to check this study: http://vmkit.llvm.org/publications/osgi_dsn.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With