Skip to content

Commit

Permalink
oio-proxy: free memory to solve oio-proxy memory consumption issue
Browse files Browse the repository at this point in the history
  • Loading branch information
IrakozeFD authored and AymericDu committed Nov 15, 2024
1 parent c23105d commit 6b88370
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static void _local_free(gpointer p) {
l->perfdata = NULL;
}
if (l->urlerrorv) {
g_ptr_array_free(l->urlerrorv, TRUE);
g_ptr_array_unref(l->urlerrorv);
}
g_free (l);
}
Expand Down Expand Up @@ -473,7 +473,7 @@ GPtrArray *oio_ext_get_urlerrorv(void) {
void oio_ext_set_urlerrorv(GPtrArray *urlerrorv) {
struct oio_ext_local_s *l = _local_ensure();
if (l->urlerrorv) {
g_ptr_array_free(l->urlerrorv, TRUE);
g_ptr_array_unref(l->urlerrorv);
}
l->urlerrorv = urlerrorv;
}
Expand Down
6 changes: 5 additions & 1 deletion proxy/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ gridd_request_replicated (struct req_args_s *args, struct client_ctx_s *ctx,
EXTRA_ASSERT(urlv->len == errorv->len);

if (urlerrorv->len > 0) {
oio_ext_set_urlerrorv(urlerrorv);
// Increase the reference count
GPtrArray *shared_urlerrorv = g_ptr_array_ref(urlerrorv);
oio_ext_set_urlerrorv(shared_urlerrorv);
}

g_strfreev(m1uv);
Expand All @@ -583,6 +585,8 @@ gridd_request_replicated (struct req_args_s *args, struct client_ctx_s *ctx,
FinishArray(ctx->urlv, gchar, urlv);
FinishArray(ctx->bodyv, GByteArray, bodyv);
FinishArray(ctx->errorv, GError, errorv);
// Unreference the urlerrov array
g_ptr_array_unref(urlerrorv);

return err;
}
Expand Down

0 comments on commit 6b88370

Please sign in to comment.