-
Notifications
You must be signed in to change notification settings - Fork 75
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
Use Boehm-Demers-Weiser Garbage Collector. #647
Merged
Merged
Conversation
This file contains 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
dimitri
force-pushed
the
fix/use-garbase-collector
branch
from
January 22, 2024 13:05
f90572a
to
aa1a747
Compare
dimitri
force-pushed
the
fix/use-garbase-collector
branch
from
January 22, 2024 16:36
aa1a747
to
3c9d5c7
Compare
hanefi
reviewed
Jan 24, 2024
From their own documentation: > The Boehm-Demers-Weiser conservative garbage collector can be used as a > garbage collecting replacement for C malloc or C++ new. It allows you to > allocate memory basically as you normally would, without explicitly > deallocating memory that is no longer useful. The collector automatically > recycles memory when it determines that it can no longer be otherwise > accessed. In pgcopydb C code base it's been hard to maintain proper malloc/free concerns while also implementing proper error-handling, which is a common problem when writing C code. In order to ease the maintenance of the code and reduce production hazards, the best way to proceed looks like automating the memory management altogether by using a Garbage Collector.
dimitri
force-pushed
the
fix/use-garbase-collector
branch
from
January 25, 2024 15:12
3c9d5c7
to
14dad72
Compare
Now that libgc is handling the memory for us, we don't need to keep track of the ownership of the buffer anymore.
shubhamdhama
approved these changes
Jan 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested locally with "lots" of database objects and didn't observed any anomaly in system memory after considerable period of time (not the best way to test this change but the most convenient I had).
hanefi
approved these changes
Jan 25, 2024
gokhangulbiz
pushed a commit
to gokhangulbiz/pgcopydb
that referenced
this pull request
Jan 26, 2024
* Use Boehm-Demers-Weiser Garbage Collector. From their own documentation: > The Boehm-Demers-Weiser conservative garbage collector can be used as a > garbage collecting replacement for C malloc or C++ new. It allows you to > allocate memory basically as you normally would, without explicitly > deallocating memory that is no longer useful. The collector automatically > recycles memory when it determines that it can no longer be otherwise > accessed. In pgcopydb C code base it's been hard to maintain proper malloc/free concerns while also implementing proper error-handling, which is a common problem when writing C code. In order to ease the maintenance of the code and reduce production hazards, the best way to proceed looks like automating the memory management altogether by using a Garbage Collector. * Revert removal of regree() calls. * Get rid of LinesBuffer.ownsBuffer. Now that libgc is handling the memory for us, we don't need to keep track of the ownership of the buffer anymore.
arajkumar
added a commit
to arajkumar/pgcopydb
that referenced
this pull request
Mar 4, 2024
pgcopydb recently switched to Boehm-Demers-Weiser Garbage Collector[1] and replaced malloc family with GC_malloc and friends. However, strdup is not replaced to GC_strdup. Solution: Use macros to replace strdup/strndup with it's GC variant. [1] dimitri#647 Signed-off-by: Arunprasad Rajkumar <ar.arunprasad@gmail.com>
dimitri
pushed a commit
that referenced
this pull request
Mar 4, 2024
pgcopydb recently switched to Boehm-Demers-Weiser Garbage Collector[1] and replaced malloc family with GC_malloc and friends. However, strdup is not replaced to GC_strdup. Solution: Use macros to replace strdup/strndup with it's GC variant. [1] #647 Signed-off-by: Arunprasad Rajkumar <ar.arunprasad@gmail.com>
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.
From their own documentation:
In pgcopydb C code base it's been hard to maintain proper malloc/free concerns while also implementing proper error-handling, which is a common problem when writing C code. In order to ease the maintenance of the code and reduce production hazards, the best way to proceed looks like automating the memory management altogether by using a Garbage Collector.
Replaces and close #613
Should fix #609