I think you have compiled the code. If the problem occurs when you run executable file then it is classical memory problem. So may need to increase memory limits before running the exe-file. there are several type of commands ex:
limit stacksize unlimited
limit memoryuse unlimited...