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 the finite element dual assignment operators #1032

Merged
merged 6 commits into from
Dec 20, 2023

Conversation

jamiebramwell
Copy link
Member

This fixes a memory leak as reported by @tepperly .

Co-authored-by: Jamie A. Bramwell <bramwell1@llnl.gov>
Co-authored-by: Tom Epperly <epperly2@llnl.gov>
@codecov-commenter
Copy link

codecov-commenter commented Nov 16, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (b2ab378) 88.95% compared to head (c3962f1) 88.88%.

Files Patch % Lines
src/serac/physics/state/finite_element_dual.hpp 42.85% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1032      +/-   ##
===========================================
- Coverage    88.95%   88.88%   -0.08%     
===========================================
  Files          153      153              
  Lines        12325    12344      +19     
===========================================
+ Hits         10964    10972       +8     
- Misses        1361     1372      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamiebramwell
Copy link
Member Author

@tepperly , I added a few extras to your patch. Let me know if this works for you.

@samuelpmishLLNL
Copy link
Contributor

out of curiosity, what was the cause of the underlying leak?

@jamiebramwell
Copy link
Member Author

out of curiosity, what was the cause of the underlying leak?

I defer to @tepperly as he developed and tested this patch.

@tepperly
Copy link
Member

tepperly commented Nov 21, 2023

out of curiosity, what was the cause of the underlying leak?

I believe it's the operator=(&& rhs) variant. After an invocation of the move operator, the compiler assumes that the rhs has been completely pilfered (i.e., all of the allocated resources owned by rhs have been moved into this or freed). When rhs is an upcast, it doesn't properly deal with all the parts of rhs leaving some orphaned pointers. This is what my valgrind logs suggested at least. Applying this patch, plugged some leaks.

In particular, I believe it was when the right hand side was an instead of FiniteElementDual, the rhs.linear_form_ was leaked.

@tepperly
Copy link
Member

The comments saying this seems like the wrong way to be doing this assignment drew my attention.

@tepperly
Copy link
Member

It would be nice if this could get in soon, so LiDO's next TPL could have it. Without this patch, my uncertain bracket problem crashes in 10-20 MMA iterations do to the Linux OOM killler which sometimes crashes my desktop.

@jamiebramwell jamiebramwell merged commit b571c8f into develop Dec 20, 2023
2 checks passed
@jamiebramwell jamiebramwell deleted the bugfix/bramwell/memory_leak branch December 20, 2023 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants