简体   繁体   English

如何避免内存错误

[英]How to avoid Memory Error

How should I proceed in order to be able to plot some data coming out from a big pytable (17GB). 我应该如何进行操作才能绘制来自大pytable(17GB)的数据。

If I try to store the values that I need, I get Memory Error , something like this: 如果我尝试存储所需的值,则会收到Memory Error ,如下所示:

for row in tab.iterrows():

    x.append(row['date'])
    y.append(row['temperature'])

    #this will not end, raises Memory Error

If I try to live update a plot with the data, without storing any values, I get this message: 如果我尝试使用数据实时更新绘图而不存储任何值,则会收到以下消息:

MemoryError
QImage: out of memory, returning null image

So then? 那呢 What should I do If I need to plot some data from such a big table? 如果需要从这么大的表中绘制一些数据,该怎么办?

Note: 注意:

Working with python 2.7 32 bits on a Windows 64-bit machine 8GB 在Windows 64位计算机8GB上使用python 2.7 32位

I know that a solution would be to use python 64, but, it should be possible to handle in python 32 too. 我知道一个解决方案是使用python 64,但是也应该可以在python 32中处理。

Try to find out what section of your data you really want to plot. 尝试找出您真正要绘制的数据部分。 It doesn't make sense to have > 1 million dots on your screen. 屏幕上有超过一百万个点是没有意义的。 You say it yourself: ... if I need to plot __some__ data from such a big table . 您自己说: ... if I need to plot __some__ data from such a big table

I haven't worked with PyTables yet, but the documentation says it's returning numpy objects, so no need to iterate over the rows. 我还没有使用PyTables ,但是文档说它正在返回numpy对象,因此不需要遍历行。

histogram, xedges, yedges = 
   numpy.histogram2d(
      tab.col('date'),
      tab.col('temperature'),
      bins=50)

pyplot.imshow(heatmap)
pyplot.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM