简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM