Closed taniabogatsch closed 8 months ago
@taniabogatsch Awesome catch, thanks for the PR!
@taniabogatsch this is neat! How did you discover this? What tool are you using?
@michaelmdresser, I discovered this in a scenario that runs the same query repeatedly on a table with a struct column. The memory kept growing while ignoring duckdb's memory limit until the process crashed. As for the tool, I am using Instruments, which comes as part of Xcode (which I don't use 😄). I can highly recommend it! I'm using both its Leaks analyzer, and its Time Profiler very frequently.
This PR ensures that go-duckdb frees
C.duckdb_struct_type_child_name(ty, j)
after retrieving theC.GoString
. Otherwise, this causes a memory leak of 16 bytes per function call. I also removed thedefer
to avoid warnings such asPossible resource leak, defer is called in the for loop
.