Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGi memory management

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:

  1. 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?
  2. 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?
like image 943
Sebastian Łaskawiec Avatar asked May 16 '11 13:05

Sebastian Łaskawiec


People also ask

What is OSGi used for?

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.

What is OSGi in simple terms?

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 framework work?

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.

What is OSGi model?

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.


2 Answers

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")

like image 119
Andreas Dolk Avatar answered Nov 15 '22 13:11

Andreas Dolk


You may also want to check this study: http://vmkit.llvm.org/publications/osgi_dsn.html

like image 22
Martin Ždila Avatar answered Nov 15 '22 15:11

Martin Ždila