celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Broekhuis <a.broekh...@gmail.com>
Subject [Native-OSGi] OSGi API: Allocated memory ownership
Date Wed, 30 May 2012 09:53:46 GMT
Hi all,

I'm looking to extract the current Celix API to the Native-OSGi project,
and running into some issues related to data/memory ownership.

Celix uses APR and memory pools for memory management. In cases where the
API returns some data, the user supplies a pool, and the framework
allocates the needed memory on that pool. This makes the user the owner of
the data.
At the moment Celix doesn't solve this nicely, sometimes data is allocated
on the supplied pool, sometimes a pointer is returned.. But this is another

Some examples of this can be found in bundle.h, eg bundle_getEntry.

In the Native-OSGi specification we don't want to use APR (or impose it on
others), so basically the question is, how do we want to handle functions
where some data is returned?

Some possible solutions:
- Keep it on the call stack, so it gets out of scope.
- Ignore APR, and allocate the memory, making the user responsible for
freeing it.

Are there any other options I am missing? And is there a common solution
for problems like this?


Met vriendelijke groet,

Alexander Broekhuis

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message