可用内存时出现Python内存错误 [英] Python memory error when memory is available

查看:192
本文介绍了可用内存时出现Python内存错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python程序,可以读取文件行并对其进行分析.该程序有意将许多行读入RAM.

I have a Python program that reads lines of files and analyzes them. The program intentionally reads many lines into the RAM.

程序在列表中添加一行(如str)时开始获取MemoryError.当我签入任务管理器时(该程序在Windows 10上运行),我看到该程序的内存为1635MB(稳定),并且计算机的总内存使用率低于50%.

The program started getting MemoryError while appending a line (as str) to list. When I check in the task manager (the program runs on Windows 10), I see that the memory of the program is on 1635MB (stable) and the total memory use of the machine is below 50%.

我读到Python并没有限制内存,那可能是什么原因?

I read that Python does not limit the memory, so what could be the reason?

技术细节:

我在Windows 10 64位16GB RAM计算机上使用Python 3.6.5.我从PowerShell终端而不是通过IDE运行程序.

I use Python 3.6.5 on Windows 10, 64-bit 16GB RAM machine. I run the program from the PowerShell terminal and not through the IDE.

推荐答案

我看到程序的内存为1635MB

I see that the memory of the program is on 1635MB

默认情况下,编译为32位的Windows EXE具有2GB的内存限制,即使在具有更多可用内存的64位OS SKU上也是如此.您的存储空间为1.6 GB,因此可能会超出此限制.

Windows EXEs compiled as 32-bit have, by default, a 2GB memory limit even when on 64-bit OS SKUs where plenty more memory is available. You're at 1.6 GB, so you're probably bumping up against this limit.

确保您正在运行Python.exe的64位版本.出于未知原因,Python.org的下载页面默认为32位.但是,如果您浏览到其给定版本的下载页面的底部, ,您可以找到适用于64位体系结构的x86-64版本.

Make sure you are running the 64-bit version of Python.exe. Python.org's download page defaults to 32-bit for unknown reasons. But if you browse to the bottom of their download page for a given release, you can find the x86-64 version for 64-bit architecture.

这篇关于可用内存时出现Python内存错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆