# yade-users team mailing list archive

## [Question #702325]: Abnormal increase in memory usage

```New question #702325 on Yade:

Hi all:
I want to use many scenes in single simulations, so I used O.switchToScene() to achieve it, and used O.run(nsteps, True) to calculate for every step in a loop.
My question is that the  memory usage will increase by about 3MB after every "O.run(nsteps, True) " code,  because there are so many  scenes and  cycleindex , after executing "O.run(nsteps, True) " code many times， then Yade crashes .

Here are some part of my code:

.....
def shear2D(param)
swap = psutil.swap_memory()
O.switchToScene(param[0])
ns = int(min(max(1e5 * numpy.max(numpy.abs(param[1])), 2),50))
dstrain = utils.Matrix3(param[1][0], param[1][1], 0, param[1][3], param[1][2], 0, 0, 0, 0)
Omega().cell.velGrad = dstrain / (ns * Omega().dt)

print(u'Remaining memory_1：', psutil.virtual_memory().available  / 1024.0 / 1024.0 / 1024.0)
print(u'used swap_1：', swap.used / 1024.0 / 1024.0 / 1024.0)

O.run(ns, True)

print(u'Remaining memory_2：', psutil.virtual_memory().available  / 1024.0 / 1024.0 / 1024.0)
print(u'used swap_2：', swap.used / 1024.0 / 1024.0 / 1024.0)

deformation = Omega().cell.getSmallStrain().norm()
st_1 = utils.getStressAndTangent(symmetry=True)
s_1 = st_1[0]
s_1 = .5 * (s_1 + s_1.transpose())
stress_dem = [s_1[0, 0], s_1[0, 1], s_1[1, 1], s_1[2, 2]]  # deformed stress
.....
# the loop likes followings
for i in scenesID:
shear2D((i,strain[i-1]))

I'm sure that  the memory increases only  relating to  " O.run(ns, True)"  by checking every each line of code，therefore I want to know the reason and how to fix it.
THANK YOU!!!

--