Skip to content

Commit

Permalink
Fix memory leak in OpenGL visualizer (#3533)
Browse files Browse the repository at this point in the history
Fixes #3530

Description of changes:
- free memory of quadric objects; they caused a 12 MiB/min memory leak in simulations containing bonds and a 3 MiB/min memory leak in simulations containing cylindrical shapes (`Cylinder`, `SpheroCylinder`, `SimplePore`, `Slitpore`)
* fix an issue in the `visualization_constraints.py` sample that prevented a `Slitpore` from being added to the list of constraints
  • Loading branch information
kodiakhq[bot] authored Feb 21, 2020
2 parents cd66da0 + 7747cab commit babd3de
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 90 deletions.
20 changes: 11 additions & 9 deletions samples/visualization_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
group.add_argument("--wall", action="store_const", dest="shape", const="Wall",
default="Wall")
for shape in ("Sphere", "Ellipsoid", "Cylinder", "SpheroCylinder",
"Stomatocyte", "SimplePore", "SlitPore", "HollowConicalFrustum"):
"Stomatocyte", "SimplePore", "Slitpore", "HollowConicalFrustum"):
group.add_argument("--" + shape.lower(), action="store_const",
dest="shape", const=shape)
args = parser.parse_args()
Expand Down Expand Up @@ -62,51 +62,53 @@
dist=20, normal=[0.1, 0.0, 1]),
particle_type=0, penetrable=True)

if args.shape == "Sphere":
elif args.shape == "Sphere":
system.constraints.add(shape=espressomd.shapes.Sphere(
center=[25, 25, 25], radius=15, direction=1),
particle_type=0, penetrable=True)

if args.shape == "Ellipsoid":
elif args.shape == "Ellipsoid":
system.constraints.add(shape=espressomd.shapes.Ellipsoid(
center=[25, 25, 25], a=25, b=15, direction=1),
particle_type=0, penetrable=True)

if args.shape == "Cylinder":
elif args.shape == "Cylinder":
system.constraints.add(shape=espressomd.shapes.Cylinder(
center=[25] * 3, axis=[1, 0, 0], direction=1, radius=10, length=30),
particle_type=0,
penetrable=True)

if args.shape == "SpheroCylinder":
elif args.shape == "SpheroCylinder":
system.constraints.add(
shape=espressomd.shapes.SpheroCylinder(center=[25] * 3, axis=[1, 0, 0],
direction=1, radius=10, length=30),
particle_type=0,
penetrable=True)

if args.shape == "Stomatocyte":
elif args.shape == "Stomatocyte":
system.constraints.add(shape=espressomd.shapes.Stomatocyte(
inner_radius=3, outer_radius=7, axis=[1.0, 0.0, 0.0], center=[25] * 3,
layer_width=3, direction=1), particle_type=0, penetrable=True)

if args.shape == "SimplePore":
elif args.shape == "SimplePore":
system.constraints.add(shape=espressomd.shapes.SimplePore(
center=[25, 25, 25], axis=[1, 0, 0], length=15, radius=12.5,
smoothing_radius=2), particle_type=0, penetrable=True)

if args.shape == "Slitpore":
elif args.shape == "Slitpore":
system.constraints.add(shape=espressomd.shapes.Slitpore(
channel_width=15, lower_smoothing_radius=3, upper_smoothing_radius=3,
pore_length=20, pore_mouth=30, pore_width=5), particle_type=0,
penetrable=True)

if args.shape == "HollowConicalFrustum":
elif args.shape == "HollowConicalFrustum":
system.constraints.add(shape=espressomd.shapes.HollowConicalFrustum(
r1=12, r2=8, length=15.0, thickness=3,
axis=[0.0, 0.0, 1.0], center=[25, 25, 25], direction=1),
particle_type=0, penetrable=True)

else:
raise ValueError("Unknown shape '{}'".format(args.shape))

for i in range(100):
rpos = np.random.random(3) * box_l
Expand Down
Loading

0 comments on commit babd3de

Please sign in to comment.