使用 Python 类和 numpy 时内存永远不会释放
基本上我不会在这里发布所有代码,但我将提供一个通用示例。我有一个类,它有一个函数来运行和创建大量值。根据我的估计,这个数组不会比 10MB 大很多。在函数中,它创建新的数组并修改应该在火车运行中的函数后收集的数组。除了返回的 tempArray 放入大数组之外,它们不在其他地方使用。这是重复的。使用的内存不断增长。我的代码或解决方法有问题吗?我在这里读到了有关 Linux 中 malloc 内存泄漏的信息: http://pushingtheweb.com/2010/06/python-and-tcmalloc/。
Basically I am not going to post all of the code here but I will provide a generic example. I have a class that has a function to run and create a large array of values. This array shouldn't be much bigger than 10MB from my estimates. Within the functions it makes new and modifies arrays that should be collected up after the functions within train run. They are not used elsewhere besides the returned tempArray which is put into the large array. This is repeated. The memory used just keeps growing and growing. Is there an issue with my code or a way around this. I have read here about memory leaks with the malloc in Linux:
http://pushingtheweb.com/2010/06/python-and-tcmalloc/.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想做什么?
temp.size
等于 200,000,000。如果这个数组的第二个维度只有 1000,如何将任何内容存储到largeArray[x,y]
中?What are you trying to do?
temp.size
equals 200,000,000. How can you store anything intolargeArray[x,y]
if the second dimension of this array is only 1000?