caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Vincenzo Ciancia <vincenzo_yahoo_addressguard-gmane@yahoo.it>
To: caml-list@inria.fr
Subject: Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
Date: Thu, 24 Nov 2005 01:00:52 +0100	[thread overview]
Message-ID: <dm2vpb$u7h$1@sea.gmane.org> (raw)

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)
{
  leave_blocking_section();
  value vstring;
  value vpath;
  value vres;
  value vtmp;
  int res=-1;
  vpath = copy_string(path);
  
  [OPERATION SPECIFIC CODE]

  if (Tag_val(vres)==1) /* Result is not Bad */
     { 
       [OPERATION SPECIFIC CODE]
     } 
  else 
  { 
    if (Is_block(Field(vres,0)))  /* This is EUNKNOWNERR of int in ocaml */ 
        res=-Int_val(Field(Field(vres,0),0));                           
    else res=-ml2c_unix_error(Int_val(Field(vres,0))); 
  } 
  enter_blocking_section(); 
  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.

Bye

Vincenzo

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


             reply	other threads:[~2005-11-24  0:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-24  0:00 Vincenzo Ciancia [this message]
2005-11-24 14:24 ` [Caml-list] " Florian Weimer
2005-11-25  9:19   ` Vincenzo Ciancia

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='dm2vpb$u7h$1@sea.gmane.org' \
    --to=vincenzo_yahoo_addressguard-gmane@yahoo.it \
    --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).