Python脚本填充内存

时间:2013-09-05 20:02:02

标签: python psse

我正在编写一个累积消耗内存的脚本,我不知道如何解决这个问题。任何帮助或建议都表示赞赏。

Python垃圾收集器以某种方式失败,发生了什么?

代码示例如下,一些注意事项如下 我怀疑罪魁祸首是psspy,但我无法访问其代码,是否有某种解决方法?

ierr都是整数 variable1等是包含单个数字列表(整数,实数或复合数)的列表。

import psspy
psspy.psseinit(1200)

cases = []
... #Construction of a list of strings containing filenames like 'case010.sav'
faults = []
... #Construction of another list that doesn't contribute to the problem.

for filename in cases:
    psspy.case(filename) #It opens a 'case' that alters the output of the following functions
    ierr, variable1 = psspy.function1(parameters)
    ierr, variable2 = psspy.function2(parameters)
    ...
    ierr, variablen = psspy.functionn(parameters)
    ...
    for fault in faults:
        psspy.close_powerflow() #Documentation says it  
             #'Removes the current powerflow working case from PSS®E’s working memory.'
        psspy.case(filename)
        ...
        ierr, variable1 = psspy.function1(parameters)
        ierr, variable2 = psspy.function2(parametersl)
        ...
        ierr, variablen = psspy.functionn(parameters)
        ...

1 个答案:

答案 0 :(得分:0)

确实可能是psspy命名空间中存在某种泄漏。为了更全面地了解内存的使用位置,您应该使用one of the Python profilers