Monday, May 22, 2017

Crystal GC and "Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS Program received and didn't handle signal IOT (6)"

Using Crystal 0.22.0, sometimes the GC seems like it is slowing things down a bit or getting hung up, but it turns out that collecting more frequently doesn't seem to help much, and slows it down more overall.

When you eventually run out of memory, you'll hit (or at least I did in macOS):

Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS
Program received and didn't handle signal IOT (6)

The impact of those hangs is not remedied by doing forced cleanup, e.g.:

if GC.stats.free_bytes < 90000
  GC.collect
end

I tried that in various ways, but you can't squeeze more memory out or trick GC into running more to run faster, at least not in my testing.

I noticed in this StackOverflow answer, Mono: Too many heap sections Increase MAXHINCR or MAX_HEAP_SECTS when app takes more than 4 GB in memory, that Mono also has a problem with the Boehm GC. Perhaps the two are similar and there's a fix for Crystal or it's compilation that would help with this.

No comments: