簡體   English   中英

Python腳本充滿了內存

[英]Python script fills memory

我正在處理一個腳本,該腳本會累計消耗內存,但我不知道該如何解決。 任何幫助或建議,表示贊賞。

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)
        ...

的確可能是psspy名稱空間中存在某種泄漏。 為了更全面地了解內存的使用位置,您應該使用Python分析器之一

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM