Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Str memory leak in 3.06?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: [Caml-list] Str memory leak in 3.06?

This program leaks 10mb/sec on my machine with ocamlopt 3.06 (msvc, xp).

let _ =
   while true do
     let re = Str.regexp "foo" in ()
   done;
   ()

Inserting a call to Gc.compact in the loop doesn't affect it (well, it 
slows the loop down a bit so the leak rate drops :).

 From a brief trip in the debugger and a glance at strstubs.cpp it appears 
the custom finalizer is being called.  I didn't grovel in the actual regex 
code to see where the leak was (assuming it's not my bug and I'm supposed 
to free the regex somehow in caml code).

I also notice that the strstubs.c has the same problem I reported in 
bigarray (and that was fixed, bug #601) about using stat_alloc() to 
allocate but free() to deallocate, so it should probably be fixed here as 
well, assuming Str is going to live much longer.

Chris

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners