Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] OCam'OLE pre-release
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] OCam'OLE pre-release
> > The job of the GC is to release unreferenced objects.
> > But I don't see how this can cause a bug : it seems that your crash is
> > to a call of a COM method on a object AFTER it has been released... if
> > has been Release, then it is no longer referenced by Ocaml... so , how
can u
> > ever call a method on it ???
> Because the COM object can still be referenced from C.  You probably
> forgot to do an AddRef somewhere, e.g. when extracting a COM object
> reference from its Caml wrapper.
> Reference count management sure is tricky...

If you're using OCamole to manipulate COM objects and then passing them back
to C, your C code need to call AddRef on the retreived COM object since
OCamole GC'ed process does not respect the COM spec (caller is responsible
from Release, callee call AddRef )

Simply use the following function :

IUnknown *get_com_object( value v ) {
    IUnknown *o = IUnknown_val(v);
    return o;

Nicolas Cannasse

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: