'Why identical python code crashes laptop but not desktop?

I am running a python code on Pycharm on my laptop and after some time, I get the error

numpy.core._exceptions.MemoryError: Unable to allocate 20.8 MiB for an array with shape (2730019,) and data type int64

The error happens at a specific line when using .loc

for index, row in dfUnique.iterrows():
    newdf = df.loc[ ( condition 1 ) &  (condition 2 ) 
          & (condition 3 ) & (condition 4 )   , : ]

This is a new laptop with 64GB RAM. I am running the identical code with the same Python version on my desktop and it is running with no problem.

I followed some advice and changed the virtual memory in the performance options (the paging file) on the laptop but no luck.

I looked at the task manager on both the desktop and the laptop, while the code is running, and I could see that the desktop usage of memory is stable at 27% (very stable). However, this memory utilization on the laptop is varying a lot. It goes to the 90s% and down to the 40s%. I was observing the memory usage at the crash on the laptop and it was not highy. It was in the 60s%.

I do not think datatype is an issue because the same identical code is running well on the desktop. I believe it is something in the computer setting. It is a new laptop and probably I am missing some of the settings.

I appreciate any help. Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source