Version française
Home     About     Download     Resources     Contact us    
Browse thread
Efficency of varient types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <ncannasse@m...>
Subject: Re: [Caml-list] Obj or not Obj
 > Just a small word about one of my bad experiment with Obj about tail rec
 > map ... it is easy to get a tail
 > rec map using Obj to make ocaml's list mutable ... it is just slower
 > that the original map and using roughly the same
 > amount of memory, because every cons cell  you gain ... is now in the
 > list of grey val as soon as your list does not
 > fit in the minor heap anymore !! So even writing you own mutable_list
 > type would be as bad !
 >
 > Explanation: the list of grey val is a list of pointers from the major
 > heap to the minor heap which
 > are created when using mutable data structure and which would break
 > incremental GC if each minor GC did not scan
 > the list of grey val) ...

This is not correct.
When you're building a mutable list you're allocating first in the minor 
heap, then all cons go into the major heap at once, so only the "last" 
cons before a GC cycle is greyed. It is indeed true that for short 
lists, using the stack is better than using mutable structures.

But using the stack is getting speed against correctness, since it will 
overflow for big lists.

Nicolas