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 issue 2046: Memory leak during btree(agtype) (#2060) #2070

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

jrgemignani
Copy link
Contributor

@jrgemignani jrgemignani commented Aug 22, 2024

Fixed the memory leaks during a btree index build.

The issue has to do with how PostgreSQL allocates and frees its memory. Usually, contexts are destroyed, freeing up the memory in that context for the functions. However, sometimes this destruction happens way too late for it to be helpful. In the case of btree compare, the context destruction doesn't happen until after the sort has completed. The solution is to add in pfrees to manage the memory we use, ourselves.

Additionally, propagated these changes to a few other functions. More PRs will be created to address other locations where this applies.

No regression tests were impacted.
No additionall regression tests are needed.

Resolved Conflicts:
src/backend/utils/adt/agtype.c

Fixed the memory leaks during a btree index build.

The issue has to do with how PostgreSQL allocates and frees its
memory. Usually, contexts are destroyed, freeing up the memory in
that context for the functions.  However, sometimes this destruction
happens way too late for it to be helpful. In the case of btree
compare, the context destruction doesn't happen until after the sort
has completed. The solution is to add in pfrees to manage the memory
we use, ourselves.

Additionally, propagated these changes to a few other functions. More
PRs will be created to address other locations where this applies.

No regression tests were impacted.
No additionall regression tests are needed.
Conflicts:
	src/backend/utils/adt/agtype.c
@github-actions github-actions bot added PG15 PostgreSQL15 override-stale To keep issues/PRs untouched from stale action labels Aug 22, 2024
@MuhammadTahaNaveed MuhammadTahaNaveed merged commit 40ecc05 into apache:PG15 Aug 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
override-stale To keep issues/PRs untouched from stale action PG15 PostgreSQL15
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants