[gambit-list] Re： Re： Re： Regarding garbage collection
peter19852001 at yahoo.com.hk
Thu Sep 10 21:59:01 EDT 2009
Thanks for the suggestion, I will try it.
----- 郵件原件 ----
寄件人﹕ Marc Feeley <feeley at iro.umontreal.ca>
收件人 peter lo <peter19852001 at yahoo.com.hk>
副本(CC) Pavel Dudrenov <dudrenov at gmail.com>; gambit-list at iro.umontreal.ca
傳送日期﹕ 2009 年 9月 10 日 星期四 下午 8:27:54
主題： Re: Re： [gambit-list] Re： Regarding garbage collection
On 9-Sep-09, at 10:42 PM, peter lo wrote:
> By the way, I am currently trying to reduce the allocation of short-lived objects, I am sure there are general tips on the web about this, but I am not sure if there are tips more specific to Gambit Scheme, taking into account its garbage collector.
I suggest that you represent your "lists" using extensible vectors, implemented with plain vectors. The value at index 0 is really the number of active elements in the extensible vector. When the vector is full, a slightly longer (by a factor of say 20% more) is allocated and the previous content is copied to it. This representation is up to 6 times more compact than the list representation for long enough "lists", when using Gambit. That's because each element in the list requires a pair, and each pair occupies 6 words of memory, header+car+cdr=3, but they are movable objects so the same space must be reserved in the "to-space". For long enough vectors (255 elements or more) each element occupies one word because the vector is "still" (no need to reserve space in the "to-space").
Yahoo!香港提供網上安全攻略，教你如何防範黑客! 請前往 http://hk.promo.yahoo.com/security/ 了解更多!
More information about the Gambit-list