The Crystal Programming Language Forum

Is there a command-line config to limit the size of the crystal heap memory?

When trying to debug memory usage, is there a config that I can pass to my crystal executable that would limit the size of its heap, so that it doesn’t grow indefinitely?

That’s particularly useful when debugging memory leaks and you want to cause an out-of-memory error sooner rather than later.

In Java you can do -Xmx4g

Crystal uses the boehm GC, so anything you can configure there you can configure here too:

It seems you can pass an GC_MAXIMUM_HEAP_SIZE environment variable to the executable:

3 Likes