Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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)
{
  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