caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Warp" <warplayer@free.fr>
To: "OCaml" <caml-list@inria.fr>
Subject: [Caml-list] Garbage Collect Problem in Library
Date: Thu, 27 Dec 2001 22:45:22 +0100	[thread overview]
Message-ID: <001f01c18f1f$c9ab9d30$99c20b50@warp> (raw)

I got some trouble with the garbage collector.
I manage to make callbacks from my dynamic linked library, passing it
the callbackN_exn C API function address when it loads.
Now i'm doing theses things :

value caml_createwindow( value callback ) {
    HWND handle_of_window = CreateWindow()
    value v = alloc( 4 , MY_TAG ); // alloc is also a reference to
interpreter alloc function
    Store_field( v , 0, handle_of_window ); // here we also got a "modify"
interpreter-call
    Store_field( v , 1, callback_value );
    SetWindowData( handle_of_window, v );
    return v;
}

So , the user got the ' v ' caml value which mainly contains the real handle
of the window and the callback.
And the window itself can obtain ' v ' from handle by calling
etWindowData( handle_of_window );

in the window proc I'm getting that ' v ' data like that and then I'm
calling caml callback.
All it's fine, but after 10 seconds, the garbage collector collects my ' v '
data
( I can see that the Tag_val is set to Zero ).

How can i prevent that ?
Shall I use CAMLparamX and other garbage-living-in-harmony-stuff ?
Theses macros are using local_root so do I have to make my library ask the
current local_root from the interpreter ?

Thanks for any help !

Warp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


                 reply	other threads:[~2001-12-27 21:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001f01c18f1f$c9ab9d30$99c20b50@warp' \
    --to=warplayer@free.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).