Version française
Home     About     Download     Resources     Contact us    
Browse thread
let x = ... in object ...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Guillaume Hennequin <guillaume.hennequin@e...>
Subject: Re: [Caml-list] let x = ... in object ...
> # class a = let () = print_endline "hello" in object end;;
> hello
> class a : object  end
>
>
> Maybe you mean the following:
>
>
?
well, I have just tested this in the toplevel

class a n =
  let x = Array.make_matrix n n 0. in
object(self)
  val y = Array.init n (fun i -> Array.copy x.(i))
  method y = y
end ;;

let mya = new a 10000 ;;

---------> memory consumption 78.5 (from top)

Gc.full_major () ;;

---------> memory consumption is still 78.9

let mya = () ;;
Gc.full_major () ;;

---------> memory consumption is now 0.1

Furthermore, in a fresh ocaml toplevel,
let x = Array.make_matrix 10000 10000 0. ;;
---------> memory consumption = 39.5
(half of the previous memory usage)

So, it seems that x, although not useful after the object creation, is not
garbage collected.

??

Cheers
Guillaume.