my parallel code demo.cr is this:
def test(num : Int32)
num.times do |line|
proc = ->(x : Int32) do
spawn do
# to do something
end
end
proc.call(line)
end
end
inf = ARGV[0].to_i
test(inf)
Fiber.yield
$crystal --version
Crystal 0.31.1 [0e2e1d067] (2019-09-30)
LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
after build with --release -Dpreview_mt
, then run get error:
$ export CRYSTAL_WORKERS=2;./demo 100 # no error,when 100
$ export CRYSTAL_WORKERS=2;./demo 1000000
Unhandled exception: Cannot allocate new fiber stack: Cannot allocate memory (Errno)
GC Warning: Failed to expand heap by 2228224 bytes
GC Warning: Failed to expand heap by 262144 bytes
GC Warning: Out of Memory! Heap size: 6 MiB. Returning NULL!
Invalid memory access (signal 11) at address 0x6018
[0x4380b6] ???
[0x437a47] __crystal_sigfault_handler +263
[0x3143a0f130] ???
[0x423415] ???
[0x417fd2] ???
[0x415151] ???
[0x42fb93] ???
[0x42dfce] ???
[0x4108c7] main +55
[0x3142e21b45] __libc_start_main +245
[0x40c719] ???
[0x0] ???
$export CRYSTAL_WORKERS=3;./demo 1000000
Unhandled exception: Cannot allocate new fiber stack: Cannot allocate memory (Errno)
from ???
thanks ~
Regards