rem
rem

Reputation: 893

make GHC to do more GCs?

In order to obtain a more accurate measure of the maximium live size of some programs, I'd like to have the runtime system to do more frequent garbage collections. Are there flags to GHC that directly/indirectle result in more GCs? I know inserting performGC can achive that to some extent, but there are quite a few programs to instrument.

Upvotes: 2

Views: 153

Answers (2)

sclv
sclv

Reputation: 38901

For direct increase in GCs you can set the -Iseconds flag to something lower than 0.3 to increase the frequency of idle GC. You can also set -c to use a compacting algo which should generally reduce memory usage (to give a closer approx to actual memory used rather than GC overhead). You may also want to set -Asize to something lower than 512k, which by giving a smaller allocation area should generally increase the no. of GCs.

Upvotes: 2

sapanoia
sapanoia

Reputation: 789

I would advise against forcing a higher frequency of GCs unless you specifically know a better suited GC-tuning for your code. GC runs can be very expensive.

Yes, your program uses "too much" memory, but this lenience is what makes the GC perform well. If you allow an overhead of 2-3 times of the memory that is strictly needed (do not know figures for GHCs GC though), GC runs can be scheduled much more infrequently.

You say you do not want to turn on memory profiling, because it interferes with optimizations, but forcing the GC may be worse. If you increase the pressure on the heap too much, you may end up benchmarking GC runs.

Upvotes: 0

Related Questions