BJ is right, the quantity you are trying to measure is not well-defined. 
We were able to modify the Mika VM to associate each allocation with the
most local non-system class loader on the stack at the time of allocation,
which gives an answer to the question "how much memory has this bundle
allocated which has not yet been reclaimed by GC", for one possible
definition of "memory is allocated by a bundle".  But if a bundle were
generating objects which should be short-lived, but some other bundle is
obsessively cacheing them then our system would "blame" the first bundle
when in fact it is the second which is the real culprit.

Carrying out measurements when the bundle is loaded/started is probably
not very realistic either, I wouldn't expect many Java modules to allocate
all the memory they need at startup time.  For that you should be looking
at something like Fortran (prior to Fortran 90).

-- 
Chris Gray

> How do you define how much memory a bundle uses? It is generally not
> possible to do this unless you have a very specific definition of memory
> use. Bundles can extend classes imported from other bundles. Bundles can
> call other bundles which allocate memory for the caller. To which bundle
> does this memory "belong"? A bundle is a unit of encapsulation and
> classloader isolation but it is not a unit of memory isolation. From a
> memory perspective, bundles are very intertwined and it is extremely hard
> to try and disentangle them.
>
> --
>
> BJ Hargrave
> Senior Technical Staff Member, IBM
> OSGi Fellow and CTO of the OSGi Alliance
> [email protected]
>
> office: +1 386 848 1781
> mobile: +1 386 848 3788
>
>
>
>
>
> From:   masti whoknows <[email protected]>
> To:     "[email protected]" <[email protected]>,
> Date:   2011/11/17 12:51
> Subject:        [osgi-dev] Question about Memory Usage per Bundle
> Sent by:        [email protected]
>
>
>
> Hi,
>
>      I am using OSGi to create a plug & play framework. My goal is to
> measure how much memory each bundle is using. Is there a way to do this
> dynamically when the bundle is loaded/started? Please note I don't want to
> use any external tools. I want to do it while the system is running.
>
>    Any help is highly appreciated.
>
> Thanks
> Masti_______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to