* Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
@ 2005-11-24 0:00 Vincenzo Ciancia
2005-11-24 14:24 ` [Caml-list] " Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Vincenzo Ciancia @ 2005-11-24 0:00 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
2005-11-24 0:00 Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1 Vincenzo Ciancia
@ 2005-11-24 14:24 ` Florian Weimer
2005-11-25 9:19 ` Vincenzo Ciancia
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2005-11-24 14:24 UTC (permalink / raw)
To: Vincenzo Ciancia; +Cc: caml-list
* Vincenzo Ciancia:
> My C callbacks, which then call back ocaml, look like this:
> leave_blocking_section();
> vpath = copy_string(path);
I don't think it's allowed to invoke the Caml allocator while not
holding the run-time library lock.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1
2005-11-24 14:24 ` [Caml-list] " Florian Weimer
@ 2005-11-25 9:19 ` Vincenzo Ciancia
0 siblings, 0 replies; 3+ messages in thread
From: Vincenzo Ciancia @ 2005-11-25 9:19 UTC (permalink / raw)
To: caml-list
Florian Weimer wrote:
>> leave_blocking_section();
>
>> vpath = copy_string(path);
>
> I don't think it's allowed to invoke the Caml allocator while not
> holding the run-time library lock.
That's why I hold the lock by calling "leave_blocking_section" at the
beginning of the function - it's "enter_blocking_section" that releases the
lock :)
I guess I will have to exclude pieces of code until the memory leak
disappears...
V.
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-11-25 9:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-24 0:00 Memory leak with ocaml 3.09 but not with ocaml <= 3.08.1 Vincenzo Ciancia
2005-11-24 14:24 ` [Caml-list] " Florian Weimer
2005-11-25 9:19 ` Vincenzo Ciancia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox