caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Memory leak & slowdown
@ 2009-06-05 14:00 Dawid Toton
  2009-06-05 15:39 ` [Caml-list] " Richard Jones
  2009-06-05 16:21 ` Dawid Toton
  0 siblings, 2 replies; 4+ messages in thread
From: Dawid Toton @ 2009-06-05 14:00 UTC (permalink / raw)
  To: caml-list

I have an OCaml program using GTK running on Windows, using multiple 
threads.

The overall memory usage grows significantly over time, but I don't know 
why. After it consumes several MB extra, it slows considerably and 
becomes unusable, so I have to fix this.

Is it possible that this is related to GC compaction being turned off? 
Additional calls to Gc.compact seemingly don't help.

The memory usage grows only when the main processing loop is working. 
After the function exists, the memory is not freed. Moreover, if I start 
it again, it 'reuses' the leaked memory. The second execution of the 
loop takes more memory only after it takes more time than the previous one.

This made me thinking that it's just some container growing but not 
shrinking. So I checked my toplevel values with the objsize library, but 
I managed to trace down only a fraction of the allocated memory and the 
sizes I get don't grow.

How to do memory profiling?

The program can have about 10MB of useful data and 200MB of something I 
don't know. How to check what is this?

Dawid


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Memory leak & slowdown
  2009-06-05 14:00 Memory leak & slowdown Dawid Toton
@ 2009-06-05 15:39 ` Richard Jones
  2009-06-05 15:55   ` Dawid Toton
  2009-06-05 16:21 ` Dawid Toton
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Jones @ 2009-06-05 15:39 UTC (permalink / raw)
  To: Dawid Toton; +Cc: caml-list

On Fri, Jun 05, 2009 at 04:00:01PM +0200, Dawid Toton wrote:
> I have an OCaml program using GTK running on Windows, using multiple 
> threads.
> 
> The overall memory usage grows significantly over time, but I don't know 
> why. After it consumes several MB extra, it slows considerably and 
> becomes unusable, so I have to fix this.

Could this be the GtkListView / register_global_root problem
in lablgtk?

http://caml.inria.fr/pub/ml-archives/caml-list/2005/08/7468da0a1e9d9891bc4cdf13eb725a51.en.html

You might want to instrument the [caml_]register_global_root function
and see how often it gets called.

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Memory leak & slowdown
  2009-06-05 15:39 ` [Caml-list] " Richard Jones
@ 2009-06-05 15:55   ` Dawid Toton
  0 siblings, 0 replies; 4+ messages in thread
From: Dawid Toton @ 2009-06-05 15:55 UTC (permalink / raw)
  To: caml-list


> 
> You might want to instrument the [caml_]register_global_root function
> and see how often it gets called.

Is it possible to enable profiling in the compiler in Windows or Cygwin 
environment? Cygwin has gprof, but OCaml's configure script says 'no 
profiling'.

Dawid


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Memory leak & slowdown
  2009-06-05 14:00 Memory leak & slowdown Dawid Toton
  2009-06-05 15:39 ` [Caml-list] " Richard Jones
@ 2009-06-05 16:21 ` Dawid Toton
  1 sibling, 0 replies; 4+ messages in thread
From: Dawid Toton @ 2009-06-05 16:21 UTC (permalink / raw)
  To: caml-list


> The overall memory usage grows significantly over time, but I don't know 
> why. After it consumes several MB extra, it slows considerably and 
> becomes unusable, so I have to fix this.

I'm still unable to figure out what is the allocated memory, but I 
discovered few things:

* there is available (somewhat hidden) version of memprof patch that 
works with 3.10.0:
   http://www.pps.jussieu.fr/~smimram/docs/ocaml-3.10.0-memprof.patch
* It seems that I can't use gprof with OCaml programs in Windows


I can roughly remember I had memory leaks some time ago if I allocated 
big arrays in expose event handler (with lablgtk2) - still have to 
verify this.

Dawid


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-05 16:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 14:00 Memory leak & slowdown Dawid Toton
2009-06-05 15:39 ` [Caml-list] " Richard Jones
2009-06-05 15:55   ` Dawid Toton
2009-06-05 16:21 ` Dawid Toton

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