Error turns up in 300*300*300 porous media

I want to apply the porous media model to a 300300300 cuboid model. But errors came out. When I change the model to smaller one, say 200200200 cuboid model, the program went quite well.

The error info is following:
Creation of the lattice.
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc
Aborted (core dumped)

The model I use is the permeability.cpp. I want to input the 300 cuboid samples into this code. The data has been recreated through the method in file create.m in Matlab.