Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocaml DLL and memory leaks
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitry Bely <dmitry.bely@g...>
Subject: Ocaml DLL and memory leaks
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