I have a script which uses a loop to generate data from a set of arrays:
def mapping_func(QDdrive):
start = tfunc()
# this takes some input parameter and builds an array
HCavQD = CavSBHam(QDDet, QDdrive, g_coup, CavDet, N)
# this builds another array
liou = diss(HCavQD, szCavQD, alp, wc, beta, gamma, kappa, N)
# this builds a third and final array
st = steadystate(HCavQD, [liou], method = 'direct')
# from the above array find these numbers
g1QD = (spCavQD * smCavQD * st).tr()
g1Cav = (adCavQD * aCavQD * st).tr()
gcohQD = (spCavQD * st).tr() * (smCavQD * st).tr()
gcohCav = (adCavQD * st).tr() * (aCavQD * st).tr()
end = tfunc()
print 'it took me %r seconds to do that calculation' % (end-start)
#remove variables above
del liou, HCavQD, st
collect()
return [g1QD, gcohQD, g1Cav, gcohCav]
# map above function over the list drives
glist = [mapping_func(d) for d in drives]
After each loop the memory usage of the programme increases massively, even though I have used del
on all the appropriate variables used. Naively I would have thought that the only thing being stored to memory are the four numbers returned by the function. Does anybody know why this might be/give some insight into the problem?
I have tried using a for
loop rather than map with a similar outcome.
Thanks in advance,
J