Skip to content

Commit

Permalink
Fix memory leak in function telemetry
Browse files Browse the repository at this point in the history
hash_create will create the hash table in TopMemoryContext unless
explicitly requested to create in different memory context. The
function telemetry code did not explicitly request a different
context leading to a memory leak.
  • Loading branch information
svenklemm committed Jul 20, 2022
1 parent 63a80ee commit 5bff287
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/telemetry/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,12 @@ function_telemetry_increment(Oid func_id, HTAB **local_counts)
HASHCTL hash_info = {
.keysize = sizeof(Oid),
.entrysize = sizeof(FnTelemetryEntry),
.hcxt = CurrentMemoryContext,
};
*local_counts =
hash_create("fn telemetry local function hash", 10, &hash_info, HASH_ELEM | HASH_BLOBS);
*local_counts = hash_create("fn telemetry local function hash",
10,
&hash_info,
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
}

entry = hash_search(*local_counts, &func_id, HASH_ENTER, &found);
Expand Down

0 comments on commit 5bff287

Please sign in to comment.