From e8b78f8208971a28e566198d38e43ad5f49a9009 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 7 Apr 2021 16:46:18 -0700 Subject: [PATCH] Fixed memory leak of Ruby arena objects. (#8465) In our free() method, we were freeing the memory from the upb arena but we were failing to free the memory for the Ruby arena object. This was causing every Ruby arena object to leak: even though the objects were getting GC'd, the underlying memory was not getting released. Co-authored-by: Joshua Haberman --- ruby/ext/google/protobuf_c/protobuf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index 63c7b9ab72..19917fe4f1 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -180,6 +180,7 @@ static void Arena_mark(void *data) { static void Arena_free(void *data) { Arena *arena = data; upb_arena_free(arena->arena); + xfree(arena); } static VALUE cArena;