What version of the Dialog compiler are you using? 0m/03 had some issues with per-object variables and heap space usage (see this thread: Heap space exhausted - solution and why ), so if your program uses a lot of those, and you’re using a version of Dialog earlier than 1a/01, the first thing to try is updating the compiler. You might also take a look at this thread: Heap space exhausted: What do you do now? , where @Draconis has laid out a number of optimizations not mentioned in the documentation.