Memory leaks for long-running scripts
Had a script running overnight (optimizations off of random initial start positions) and this morning it still wasn't finished and it had slowed to a crawl. Python memory usage had jumped up to 80%.
I think running this code would reproduce it (this code has no random start, it's just optimizing from the standard initial position many times, but it's the same idea):
from topfarm.examples.iea37 import get_iea37_initial, get_iea37_constraints, \
get_iea37_cost
from topfarm.plotting import NoPlot, XYPlotComp
def optimize_iea37_locs(n_wt, driver, wec=1, initial=None,
wd=np.array(range(16)) * 22.5):
if initial is None:
initial = get_iea37_initial(n_wt)
tf = TopFarmProblem(
dict(zip('xy', (initial[:, :2]).T)),
get_iea37_cost(n_wt, wec=wec, wd=wd),
constraints=get_iea37_constraints(n_wt),
driver=driver,
plot_comp=XYPlotComp()) # NoPlot, XYPlotComp
cost, state, recorder = tf.optimize()
return cost, state, recorder
n_rand = 500
n_wt = 64
driver = EasyScipyOptimizeDriver(maxiter=300)
final_all = np.empty((n_wt, 2, len(nwds), n_rand))
aep_final = np.full((len(nwds), n_rand), np.nan)
for i_rand in n_rand:
cost, state, recorder = optimize_iea37_locs(n_wt, driver)
aep_final[iopt, i_rand] = -cost
final_all[:, :, iopt, i_rand] = np.c_[state['x'], state['y']]