From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA08158; Thu, 27 Dec 2001 22:47:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA11605 for ; Thu, 27 Dec 2001 22:47:23 +0100 (MET) Received: from mel-rto3.wanadoo.fr (smtp-out-3.wanadoo.fr [193.252.19.233]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBRLlMT24425 for ; Thu, 27 Dec 2001 22:47:22 +0100 (MET) Received: from amyris.wanadoo.fr (193.252.19.150) by mel-rto3.wanadoo.fr; 27 Dec 2001 22:47:22 +0100 Received: from warp (80.11.194.153) by amyris.wanadoo.fr; 27 Dec 2001 22:47:19 +0100 Message-ID: <001f01c18f1f$c9ab9d30$99c20b50@warp> From: "Warp" To: "OCaml" Subject: [Caml-list] Garbage Collect Problem in Library Date: Thu, 27 Dec 2001 22:45:22 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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