Skip to content

Commit 5cf974f

Browse files
debug memory leak in wave
1 parent 8946291 commit 5cf974f

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

examples/wave.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from pytools.obj_array import flat_obj_array
3131

32-
from grudge.shortcuts import make_visualizer
32+
# from grudge.shortcuts import make_visualizer
3333
import grudge.op as op
3434

3535
from mirgecom.discretization import create_discretization_collection
@@ -124,10 +124,11 @@ def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False):
124124
logmgr_add_device_memory_usage(logmgr, queue)
125125
logmgr_add_mempool_usage(logmgr, alloc)
126126

127-
logmgr.add_watches(["step.max", "t_step.max", "t_log.max"])
127+
logmgr.add_watches(["step.max"])
128128

129129
try:
130-
logmgr.add_watches(["memory_usage_python.max", "memory_usage_gpu.max"])
130+
logmgr.add_watches(["memory_usage_mempool_managed.max",
131+
"memory_usage_mempool_active.max"])
131132
except KeyError:
132133
pass
133134

@@ -137,33 +138,36 @@ def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False):
137138
vis_timer = IntervalTimer("t_vis", "Time spent visualizing")
138139
logmgr.add_quantity(vis_timer)
139140

140-
vis = make_visualizer(dcoll)
141+
# vis = make_visualizer(dcoll)
141142

142143
def rhs(t, w):
143144
return wave_operator(dcoll, c=wave_speed, w=w)
144145

145146
compiled_rhs = actx.compile(rhs)
146147
fields = force_evaluation(actx, fields)
147148

149+
import gc
150+
148151
t = 0
149152
t_final = 1
150153
istep = 0
151154
while t < t_final:
152155
if logmgr:
153156
logmgr.tick_before()
154157

158+
gc.collect()
159+
155160
fields = rk4_step(fields, t, dt, compiled_rhs)
156161
fields = force_evaluation(actx, fields)
157162

158-
if istep % 10 == 0:
159-
if use_profiling:
160-
print(actx.tabulate_profiling_data())
161-
print(istep, t, actx.to_numpy(op.norm(dcoll, fields[0], 2)))
162-
vis.write_vtk_file("fld-wave-%04d.vtu" % istep,
163-
[
164-
("u", fields[0]),
165-
("v", fields[1:]),
166-
], overwrite=True)
163+
if istep == 10:
164+
gc.set_debug(gc.DEBUG_SAVEALL)
165+
gc.collect()
166+
gc.set_debug(0)
167+
obj_list = gc.garbage
168+
169+
for obj in obj_list:
170+
print(type(obj))
167171

168172
t += dt
169173
istep += 1

0 commit comments

Comments
 (0)