1 | initial version |

You need to determine how much memory your matrices are taking. I am not sure how much memory each integer takes. But let us assume that each entry of the matrix is an integer of 32 bits which is 4 bytes. Then you have a matrix of size 4x600x600 which is more than 1M. You are running this for 100 iterations, and have at least 3 matrices in each iterations which already gives 300M of memory. And then you have 4 different values of N, which gives 1.2G of memory. And this is a lower estimate assuming that none of the other objects are taking up any significant memory, no more matrices are being created in your code, and assuming that numpy/python is not doing any garbage collection.

You need to rethink how you want to run your simulation. Are

*all*the entries of your matrix getting allocated some value in the for loop? If so, then do not reinitialize a new zero matrix every time.Can you redo your computations without copying the matrices? If not, maybe you want to just copy the values of the matrix M manually into the other two matrices so that you are not allocating new memory every time. The program will be slower but you will not run out of memory.

Eventually, *you* will have to think about your simulation and decide how you want to do it, what simplifications you can perform, etc.

2 | No.2 Revision |

You need to determine how much memory your matrices are taking. I am not sure how much memory each integer takes. But let us assume that each entry of the matrix is an integer of 32 bits which is 4 bytes. Then you have a matrix of size 4x600x600 which is more than 1M. You are running this for 100 iterations, and have at least 3 matrices in each iterations which already gives 300M of memory. And then you have 4 different values of N, which gives 1.2G of memory. And this is a lower estimate assuming that none of the other objects are taking up any significant memory, no more matrices are being created in your code, and assuming that numpy/python is not doing any garbage collection.

You need to rethink how you want to run your simulation. Are

*all*the entries of your matrix getting allocated some value in the for loop? If so, then do not reinitialize a new zero matrix every time.Can you redo your computations without copying the matrices? If not, maybe you want to just copy the values of the matrix M manually into the other two matrices so that you are not allocating new memory every time. The program will be slower but you will not run out of memory.

Eventually, *you* will have to think about your simulation and decide how you want to do it, what simplifications you can perform, etc.

Also, you may want to run sage under ulimit like this: `ulimit -v <for example half of your total ram>`

in order to prevent system crashes. If you want a shell command here it is

```
$ ulimit -v $(( $( free | sed -n -e '/^Mem:/{s/^Mem:[ ]*\([0-9]\{1,\}\) .*$/\1/p}' )/2 ))
$ /path/to/sage
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.