caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocaml DLL and memory leaks
@ 2007-05-09 10:45 Dmitry Bely
  2007-05-10 17:21 ` [Caml-list] " Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Bely @ 2007-05-09 10:45 UTC (permalink / raw)
  To: Caml List

I have an Ocaml module packed into DLL that is dynamically loaded by
the main C program. What should I do to free all memory taken by Ocaml
runtime when the DLL is unloaded? The following scenario does not
work:

  [...]
  case DLL_PROCESS_ATTACH:
    [...]
    caml_startup(argv);
    break;

  case DLL_PROCESS_DETACH:
    value* at_exit = caml_named_value("Pervasives.do_at_exit");
    if (at_exit != NULL) caml_callback_exn(*at_exit, Val_unit);
    value* compact = caml_named_value("Gc.compact");
    if (compact != NULL) caml_callback_exn(*compact, Val_unit);
    /* Memory leak! */

Any idea?

- Dmitry Bely


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Ocaml DLL and memory leaks
  2007-05-09 10:45 Ocaml DLL and memory leaks Dmitry Bely
@ 2007-05-10 17:21 ` Xavier Leroy
  2007-05-11 13:19   ` Dmitry Bely
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 2007-05-10 17:21 UTC (permalink / raw)
  To: Dmitry Bely; +Cc: Caml List

> I have an Ocaml module packed into DLL that is dynamically loaded by
> the main C program. What should I do to free all memory taken by Ocaml
> runtime when the DLL is unloaded?

This si not possible currently.  I agree the OCaml runtime system
should one day provide a cleanup function to do this.

Regards,

- Xavier Leroy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Ocaml DLL and memory leaks
  2007-05-10 17:21 ` [Caml-list] " Xavier Leroy
@ 2007-05-11 13:19   ` Dmitry Bely
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Bely @ 2007-05-11 13:19 UTC (permalink / raw)
  To: Caml List

On 5/10/07, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> > I have an Ocaml module packed into DLL that is dynamically loaded by
> > the main C program. What should I do to free all memory taken by Ocaml
> > runtime when the DLL is unloaded?
>
> This is not possible currently.  I agree the OCaml runtime system
> should one day provide a cleanup function to do this.

It turned out that at least for Microsoft C runtime things are not
that bad. If you statically link CRT, it will clean up all resources
itself.

- Dmitry Bely


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-11 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-09 10:45 Ocaml DLL and memory leaks Dmitry Bely
2007-05-10 17:21 ` [Caml-list] " Xavier Leroy
2007-05-11 13:19   ` Dmitry Bely

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).