Bad Memory Allocation

I run a program of porous media fluid flow, and the porous media is read from an STL file. It runs successfully when the domain is spited by 250 lattices. But when I split it into 1000 lattices, the program is terminated because of bad memory allocation.

terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc

Then I tried the provided example program ‘aneurysm.cpp’ with higher resolution, which is changed from 100 to 10000. And it also crashed because of bad allocation. Dose anyone know how to solve the problem? Thank you very much!