Browse thread
memory usage
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-01-12 (17:57) |
From: | John Lepikhin <john@i...> |
Subject: | Re: [Caml-list] Re: memory usage |
> 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.