[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is best way to limit memory alloc?
From: |
Ludovic Courtès |
Subject: |
Re: What is best way to limit memory alloc? |
Date: |
Wed, 29 Aug 2007 17:20:07 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Roland Orre <address@hidden> writes:
> I found out that I had already solved the memory allocation
> problem in one way a few years ago.
> With the help of a small routine gc-heap-size, which accesses
> scm_i_master_freelist.heap_size
> scm_i_master_freelist2.heap_size
> I did:
> (define gc-heap1 (gc-heap-size 1))
> (define gc-heap2 (gc-heap-size 2))
> (let loop
> ....
> (gc-heap-size 1 gc-heap1)
> (gc-heap-size 2 gc-heap2)
> (loop ...))
> By not allowing the heap size to increase.
That seems brutal. ;-) What does `gc-heap-size' do exactly?
Another way would have been to fiddle with the `GUILE_MIN_YIELD_1' and
`GUILE_MIN_YIELD_2' environment variables. These variables tell the GC
when it should grow the heap for the first and second freelist,
respectively. More precisely, the GC does:
if (number-of-cells-collected-recently < GUILE_MIN_YIELD_X)
then
allocate-new-heap
else
run-a-collection
(This takes place in `scm_i_gc_grow_heap_p ()' and `scm_gc_for_newcell ()'.)
The default value for `GUILE_MIN_YIELD_{1,2}' is 40, which means that if
the last GC run did not yield more than 40 cells, then more heap is
allocated.
If you set it to some _higher_ value, then the GC should be more
conservative and less memory-hungry, at the cost of being slower.
Thanks,
Ludovic.