English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-24 (00:02)
From: Vincenzo Ciancia <vincenzo_yahoo_addressguard-gmane@y...>
Subject: Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
Hi all, I have a memory leak in ocamlfuse. Since fuse is based on callbacks,
and requests should be processed concurrently, I had to invert control, but
to avoid duplicate code in ocaml and c, I did things like this:

1. ocaml waits for messages from the kernel
2. then for each message received, ocaml creates an ocaml thread, and then   
calls C to allow processing of messages
3. after decoding a message (in an ocaml thread) C performs a callback to a
C callback for each operation, which in turn calls back ocaml

In this way I allow the fuse C library to decode messages, while I allow
ocaml to create threads for this purpose. 

Everything was working very well with ocaml 3.08, but using ocaml 3.09 I
have a memory leak as I said. 

My C callbacks, which then call back ocaml, look like this:

static int ops_OPNAME(ARGS)
  value vstring;
  value vpath;
  value vres;
  value vtmp;
  int res=-1;
  vpath = copy_string(path);

  if (Tag_val(vres)==1) /* Result is not Bad */
    if (Is_block(Field(vres,0)))  /* This is EUNKNOWNERR of int in ocaml */ 
    else res=-ml2c_unix_error(Int_val(Field(vres,0))); 
  return res; 

If someone gives advice on how to discover where the memory leak is, I
promise to file a bug report if it is the case.



Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it