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 #45

Conversation

psychocoderHPC
Copy link
Member

@psychocoderHPC psychocoderHPC commented Dec 11, 2023

With #44 we tried to fix the memory leak which can happen if more than one thread is allocating a new chunk.
The PR #44 was not fixing the issue and introduced a double free issue.

@michaelsippel I have not tested the PR and wrote it blindly, we need to perform a runtime test before merging.

@@ -409,9 +406,14 @@ struct ChunkedList
ChunkedList( size_t est_chunk_size = 32 )
: ChunkedList(
Allocator(),
est_chunk_size
Copy link
Member Author

@psychocoderHPC psychocoderHPC Dec 11, 2023

Choose a reason for hiding this comment

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

@michaelsippel For me it is not clear why this constructor's implementation is different to the second constructor. Why do you not compute the chunk_size in the previous version before my PR.
This means for this constructor the member was initialized to zero.

Copy link
Member

Choose a reason for hiding this comment

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

The implementation is not different, the first one just uses the default allocator (picks the allocator assigned to the current worker) and is implemented by calling the second one

Copy link
Member Author

Choose a reason for hiding this comment

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

ohh yes, thanks for the clarification. I got confused by the words chunk, chunks, Chunk, ...^^ everywhere^^ (my fault)

Copy link
Member

@michaelsippel michaelsippel left a comment

Choose a reason for hiding this comment

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

generally there is a confusion between 'chunks' & 'items' in the variable naming & comments. Otherwise I have a commit that refactors the Chunk such that it stores direct pointers instead of indices and we should build on that to implement the fix

redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
redGrapes/util/chunked_list.hpp Outdated Show resolved Hide resolved
readGrapes init and finalize is missing in `1_resource.cpp`
With ComputationalRadiationPhysics#44 we tried to fix the memory leak which can happen if more than one thread is allocating a new chunk.
The PR ComputationalRadiationPhysics#44 was not fixing the issue and introduced a double free issue.
@psychocoderHPC
Copy link
Member Author

@michaelsippel I applied your review comments and rebased against #47

@psychocoderHPC
Copy link
Member Author

generally there is a confusion between 'chunks' & 'items' in the variable naming & comments. Otherwise I have a commit that refactors the Chunk such that it stores direct pointers instead of indices and we should build on that to implement the fix

I am fine if we refactor these parts in a follow up but as long as there is no PR fix that instantly fixes the current issue of memory leaks I would like to bring it in to have a version that is working correctly.

I am also fine if this PR is not going in, both ways are possible as long as the dev branch becomes usable again.

@michaelsippel
Copy link
Member

For testing we should use small chunk sizes with many tasks since otherwise when everything fits into one chunk, the implementation will not be stressed

@psychocoderHPC
Copy link
Member Author

Unfortunately, this PR creates a deadlock :-( during testing

psychocoderHPC added a commit to psychocoderHPC/redGrapes that referenced this pull request Dec 12, 2023
Equally to
ComputationalRadiationPhysics#45 this
PR should solve the possible double free and double alloc.
psychocoderHPC added a commit to psychocoderHPC/redGrapes that referenced this pull request Dec 13, 2023
Equally to
ComputationalRadiationPhysics#45 this
PR should solve the possible double free and double alloc.
@michaelsippel
Copy link
Member

now already included in #48

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.

2 participants