The Crystal Programming Language Forum

Eliminating runtime WARNING message

I was (re)testing more code with 1.1.1 and still see an annoying runtime WARNING still being outputted that I would love to see eliminated.

When I run this code:

with very large UInt64 inputs I get these repeated WARNINGs about the allocation of very large blocks of memory, as shown in this example.

➜  crystal-projects CRYSTAL_WORKERS=8 ./twinprimes_ssoz 1299966672300000 1298760077778888
threads = 8
using Prime Generator parameters for P13
segment size = 802816 resgroups; seg array is [1 x 12544] 64-bits
twinprime candidates = 59666763915; resgroups = 40179639
each of 1485 threads has nextp[2 x 2207426] array
setup time = 0.089996 secs
perform twinprimes ssoz sieve
7 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
10 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
14 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
23 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
25 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
30 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance
34 of 1485 twinpairs doneGC Warning: Repeated allocation of very large block (appr. size 35319808):
        May lead to memory leak and poor performance

For much smaller values it doesn’t produce those warnings.

Is there a way to currently turn off those warnings, either at compile or runtime?

This is with Crystal 1.1.1 on Linux, and I have 16GB of memory on my laptop.

There’s this: Add a way to supress the warnings from the GC · Issue #4441 · crystal-lang/crystal · GitHub

Thanks @asterite that worked suppressing warnings as shown.

GC_LARGE_ALLOC_WARN_INTERVAL=1000 CRYSTAL_WORKERS=8 ./twinprimes_ssoz 1299966672300000 1298760077778888

EDIT: Had to increase to 1500 (> number threads used) to eliminate all warnings.