Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in OpenGL visualizer #3533

Merged
merged 5 commits into from
Feb 21, 2020
Merged

Conversation

jngrad
Copy link
Member

@jngrad jngrad commented Feb 21, 2020

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

The OpenGL visualizer has a memory leak rate of around 12 MiB/min
for simulations with polymers, and 3 MiB/min for simulations with
shapes containing cylinders. Memory allocated by `gluNewQuadric()`
must be freed by `gluDeleteQuadric()`.
The OpenGL.GL submodule of OpenGL 3.1.0 contains an infinite
recursive import to itself.
@jngrad
Copy link
Member Author

jngrad commented Feb 21, 2020

@christophlohrmann please check a few samples, e.g. the following are directly affected by this PR:

./pypresso ../samples/visualization_bonded.py --opengl
./pypresso ../samples/visualization_constraints.py --simplepore
./pypresso ../samples/visualization_constraints.py --slitpore
./pypresso ../samples/visualization_constraints.py --cylinder
./pypresso ../samples/visualization_constraints.py --spherocylinder

@codecov
Copy link

codecov bot commented Feb 21, 2020

Codecov Report

Merging #3533 into python will decrease coverage by <1%.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           python   #3533   +/-   ##
======================================
- Coverage      87%     87%   -1%     
======================================
  Files         536     536           
  Lines       24177   24177           
======================================
- Hits        21063   21057    -6     
- Misses       3114    3120    +6
Impacted Files Coverage Δ
src/core/polymer.cpp 93% <0%> (-6%) ⬇️
src/core/electrostatics_magnetostatics/p3m.cpp 85% <0%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd66da0...7747cab. Read the comment docs.

Copy link
Contributor

@christophlohrmann christophlohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shapes look like they are supposed to. Also memory doesn't blow up after longer runtime.
Still, in the samples, particles are on both sides of the constraints and also can hop across the constraints

@jngrad
Copy link
Member Author

jngrad commented Feb 21, 2020

I've just tried to rewrite the particle placement loop to make some shapes impossible to cross, but it didn't work for the slitpore, where particles spawn too close to each other due to the confined geometry.

Particles crossing constraints is most likely a side-effect of the force capping mechanism, which prevents the force from becoming infinite when crossing a wall or surface. Writing custom particle placement code for each constraint and validating the simulation against crashes for each constraint in CI seems too much work for such a simple sample, and will make the sample a lot more difficult to re-use by novice users.

@jngrad jngrad requested a review from fweik February 21, 2020 16:13
@KaiSzuttor
Copy link
Member

you should use energy minimization instead of force capping

@jngrad
Copy link
Member Author

jngrad commented Feb 21, 2020

We use steepest descent to minimize the energy, and then the Langevin thermostat with a high gamma. The force capping is there to prevent the simulation from crashing.

@jngrad jngrad added the automerge Merge with kodiak label Feb 21, 2020
@kodiakhq kodiakhq bot merged commit babd3de into espressomd:python Feb 21, 2020
@jngrad jngrad deleted the fix-3530 branch January 18, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Online visualization memory leak
4 participants