the initial interpretation of the error is that you have run out of available memory for the operation you attempted.
This opens two main possibilities
Your data / code are both 'correct' and simply need more memory available than you have ; if so you would try to reduce if possible your memory footprint to free up more memory, or perhaps invest in more memory
Either your data or code or both or in some way incorrect and the memory run out is a side effect of the calculation generating more data (and needing to take more memory) than would be justified, and that would be needed if the data / code were correct
We would need more information to help further I'm afraid.