From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-19T03:51:37+09:00 Subject: Re: ruby garbage collection On Mon, 19 May 2003 02:28:16 +0900, Mauricio Fern�ndez wrote: > On Sun, May 18, 2003 at 11:30:48PM +0900, Simon Strandgaard wrote: >> On Mon, 19 May 2003 00:15:33 +0900, Gaffer wrote: >> >> > an interesting aside, is there any benefit to using ruby's ALLOC etc. >> > functions over new/delete? i notice you dont, cheers >> >> I don't know the difference: new/delete versus rubys ALLOC. >> Can anyone shed some light on this ? > > If you go through Ruby's allocation (ALLOC is equivalent to xmalloc > which is normally ruby_xmalloc) the information on how much memory has > been allocated is updated. If more than malloc_limit (a changing > threshold) bytes have been allocated a GC run is performed. > > This means Ruby will not GC if you use new or malloc directly, but it > might start GC()ing in the middle of ALLOC. > > You should bypass Ruby's ALLOC if you're pretty confident that no memory > will be regained in the GC pass. > [snip ruby_xmalloc] This topic got me really confused when I started on writing ruby extensions. Therefore I think I will add a brief discussion of it to the tutorial on how to embed ruby into c++. http://metaeditor.sf.net/embed/ Should extension writers overload new so that ruby_xmalloc/ALLOC is being used ? any benefits ? Or should we just stick with new/delete ? -- Simon Strandgaard