Memory tracking and garbage collection to CLASS v3.2.0#583
Open
kcroker wants to merge 3 commits intolesgourg:masterfrom
Open
Memory tracking and garbage collection to CLASS v3.2.0#583kcroker wants to merge 3 commits intolesgourg:masterfrom
kcroker wants to merge 3 commits intolesgourg:masterfrom
Conversation
and Python classy. Works in parallel with OpenMP (default
100 threads, can be adjusted at compile time)
FIXES memory leaks when CLASS terminates on _FAILURE_ when called
from Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses Open Issues: #176 and possibly #528
Impacts Users: @hdp1213 @carlosggarcia @danielsf @mcosta18
Replaces all malloc(), realloc(), calloc(), and free() calls with reference-tracked versions. POSIX semantics are honoured. This allows all allocated memory to be freed at any time, regardless of CLASS state. FAILURE conditions have been adjusted to release all allocated memory.
This repairs memory leaks that occur when CLASS is driven from the python wrapper, but fails to complete computations for various reasons, e.g. untabulated He fraction in the reionization code, choices of model parameters during MC that result in non-viable cosmologies/intergrator precision issues, etc.
Memory is tracked with a minimal doubly-linked list. Additions occur at the head for maximal performance on allocation and free. Cooperates with OpenMP as it is used within the v3.2.0 code.
(Note that this patch does not introduce tracked memory allocations within the python wrapper, and so will not fix leaks within the wrapper, if they exist.)