For reference here is the first first part of the code. Specifically I get the error on line 59. Above there are just variables that define things. 

The x span is set to be 1 micron with conformal variable 0 mesh and the background index is set to 1.333. 

When I set the x span to be 10nm the program is not shut down due to insufficient memory but the elements are added to the build extremely slowly (140 seconds to add 5 elements). Before it used to start running the simulation in under 10 seconds. Nothing has changed but this has happened all of a sudden. 

When I construct this in GUI it works fine and I can use python to load files and save them just not create new ones.