dbaccess::ODatabaseContext cleaning its cache "too late"?

Lionel Elie Mamane lionel at mamane.lu
Tue Sep 10 09:40:41 PDT 2013

On Mon, Sep 09, 2013 at 03:35:22PM +0200, Stephan Bergmann wrote:
> On 09/07/2013 09:46 AM, Lionel Elie Mamane wrote:
>> On Tue, Aug 20, 2013 at 10:57:06AM +0200, Stephan Bergmann wrote:
>>> On 08/16/2013 03:46 PM, Lionel Elie Mamane wrote:
>>>> On Fri, Aug 16, 2013 at 02:55:35PM +0200, Stephan Bergmann wrote:

>>>>> No real insight into any of this, but would it make sense to rely on
>>>>> some explicit "commit" stimulus to do that committing, instead of
>>>>> doing it upon "dispose"

>>>> I don't understand what "commit stimulus" is.

>>> I was thinking of some "close" function (analogous to how, say, a
>>> Java class representing a file should have an explicit close()
>>> method rather than relying on a finalizer).

>> It seems the shutdown of ODatabaseContext at "dispose" time creates
>> other problems... E.g. https://bugs.freedesktop.org/69036

>> So I tried to look into this, and using a "close" that would be called
>> earlier makes sense to me, but in the context of application shutdown,
>> I don't see *who* would call it when :-| I'm a bit stuck there.

> But wouldn't every "database context" be tied to some open window,

I don't see why that would be, unless we create a "fake" window in
headless situations or for things that don't have a UI window. I'm
thinking of this scenario:

1) run
   soffice "-accept=socket,host=localhost,port=2002;urp;"
   soffice "-accept=socket,host=localhost,port=2002;urp;" --nodefault
   soffice "-accept=socket,host=localhost,port=2002;urp;" --headless
   soffice "-accept=socket,host=localhost,port=2002;urp;" --headless --nodefault
   or some such.

2) Run a python script like

   import uno
   localContext = uno.getComponentContext()

   resolver = localContext.ServiceManager.createInstanceWithContext(
			"com.sun.star.bridge.UnoUrlResolver", localContext )

   ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
   smgr = ctx.ServiceManager
   dbCtx =  smgr.createInstanceWithContext( "com.sun.star.sdb.DatabaseContext",ctx)

The ODatabaseContext that just got created, to what window would it be

> or some "shell" in sfx2 speak,

Is the notion of "shell" different than "window"? Would the above
scenario have a shell, but no window?

In the context of https://bugs.freedesktop.org/69036, I would like to
see who holds a reference to the DatabaseContext that gets closed. It
is my understanding that (because we have reference-counting garbage
collection), dispose() should actually be called as soon as nobody
holds a reference to it anymore (unless we have a reference cycle).

How can I find that out? Anything better than breaking on the
constructor and going a few frames up, and reading the code to try to
guess where the reference is leaked / stored / ..., and then breaking
on any function that returns the reference as result, etc?

My end goal is to see if I cannot rather close the putative reference
leak or break the putative cycle, so that the DatabaseContext is
disposed as soon as it is not used anymore.

I grepped through some code creating DatabaseContext, it seems to
usually hold the reference for only a *short* time.


More information about the LibreOffice mailing list