Skip to content

Conversation

Nao-ris
Copy link
Contributor

@Nao-ris Nao-ris commented Mar 26, 2025

In PR #24 I started removing memory leaks by checking them when the utility function with_db was used in unit tests.

This PR finalizes that process.

It contains a new utility class LeakChecker that checks the leaks for a unit test.
LeakChecker is added to the utility classes ReplicationTwoDbsTester and ReplicationThreeDbsTester, used to test replication use cases.
LeakChecker is also added to all tests that do not use one of the three utility function & classes.

Three new sources of memory leaks were discovered this time:

  • in src/encryptable.rs, reference was used instead of take_ownership when creating a new Encryptable
  • in src/replicator.rs, the struct Endpoint was not implementing Drop
  • in src/replicator.rs, when a Replicator was created we were not giving ownership of the CBLDatabase object to the CBLReplicatorConfiguration object

@Nao-ris Nao-ris marked this pull request as ready for review March 26, 2025 10:55
@Nao-ris Nao-ris requested a review from a team as a code owner March 26, 2025 10:55
@Nao-ris Nao-ris changed the title Add leak check to ReplicationTwoDbsTester & ReplicationThreeDbsTester utils Check memory leaks in all tests, and fix 3 memory leaks detected Mar 26, 2025
@Nao-ris Nao-ris changed the title Check memory leaks in all tests, and fix 3 memory leaks detected Check memory leaks in all tests, and fix 3 detected memory leaks Mar 26, 2025
@Nao-ris Nao-ris merged commit deeabd6 into main Mar 26, 2025
5 checks passed
@Nao-ris Nao-ris deleted the LEAK_CHECK_for_all_tests branch March 26, 2025 13:16
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.

2 participants