caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Lepikhin <john@ispsystem.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Re: memory usage
Date: Tue, 13 Jan 2009 01:56:39 +0800	[thread overview]
Message-ID: <1231782999.4376.246.camel@john-laptop> (raw)
In-Reply-To: <20090112114127.GA1568@annexia.org>

> I'm afraid to say that you'll have to post a short reproducer here
> before I can look at this further ...

I'm not sure this is the same issue. Look at this test code:

================================
let threads_counter = ref 0

let counter_mutex = Mutex.create ()

let send_data data size =
	let fd = Unix.openfile "/dev/null" [ Unix.O_WRONLY ] 0o644 in
	ignore (Unix.write fd data 0 size);
	Unix.close fd

let read_data _ =
	let fd = Unix.openfile "/dev/random" [] 0o644 in
	let buffer = String.create 1024 in
	let br = Unix.read fd buffer 0 (Random.int 1000) in
	Unix.close fd;
	ignore (Unix.select [] [] [] 0.1);
	send_data buffer br

let do_work _ =
	read_data ();

	Mutex.lock counter_mutex;
	decr threads_counter;
	Mutex.unlock counter_mutex

let _ =
	while true do
		Mutex.lock counter_mutex;
		if !threads_counter < 20 then
		begin
			incr threads_counter;

			ignore (Thread.create do_work ());
		end;
		Mutex.unlock counter_mutex;
	done;
	Unix.sleep 100
================================

It checks if thread count is less than 20. If so, new thread is created
and threads_counter incremented. After thread is done, threads_counter
is decremented.

After 5 minutes of work, RSS usage was grown from 3300KB to 5670KB on
FreeBSD 7.0 and from 976KB to 1200KB on Linux. In both cases Ocaml
3.10.2 was used.


  parent reply	other threads:[~2009-01-12 17:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12  7:41 John Lepikhin
2009-01-12  8:39 ` [Caml-list] " Richard Jones
2009-01-12  9:14   ` John Lepikhin
2009-01-12 10:45     ` Sylvain Le Gall
2009-01-12 11:28       ` [Caml-list] " John Lepikhin
2009-01-12 11:41         ` Richard Jones
2009-01-12 15:03           ` John Lepikhin
2009-01-12 19:55             ` Richard Jones
2009-01-12 17:56           ` John Lepikhin [this message]
2009-01-12 20:12             ` Richard Jones
2009-01-12 21:34               ` John Lepikhin
2009-01-12 22:01                 ` Richard Jones
2009-01-13 16:00                   ` John Lepikhin
     [not found] ` <20090112114837.GB18405@janestcapital.com>
2009-01-12 15:05   ` [Caml-list] " John Lepikhin
2009-01-12 16:29 ` Florian Hars
2009-01-12 16:44   ` John Lepikhin
2009-01-12 17:55     ` Sylvain Le Gall
2009-01-12 18:01       ` [Caml-list] " John Lepikhin
2009-01-12 18:26         ` Sylvain Le Gall

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=1231782999.4376.246.camel@john-laptop \
    --to=john@ispsystem.com \
    --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).