I'm working on a script that consumes memory cumulatively and I don't know how to solve this. Any help or suggestions are appreciated.
Python garbage collector is failing somehow, what is going on?
The code sample is below, some notes are following.
I suspect the culprit is psspy
but I don't have access to its code, is there a workaround somehow?
ierr
are all integers.
variable1
, etc are lists containing a single list of numbers (integers, reals or complexes).
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)
...
It could indeed be that there is some sort of leak in the
psspy
namespace. In order to understand more fully where the memory is being used you should use one of the Python profilers.