paleolimbot opened a new issue, #40898:
URL: https://github.com/apache/arrow/issues/40898

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   In #39302, the integration tests where nanoarrow is producing an C# is 
consuming are reporting memory leaks. These leaks are based on 
allocations/frees reported by nanoarrow's special buffer allocator, which I 
instrumented to do some printing of the results. Those adventures are in this 
gist ( https://gist.github.com/paleolimbot/257be29c926c3467b174fd83c3baf2b1 ), 
and the output that led me to this conclusion is below: basically, I 
instrumented the special allocator to print to stdout and did some scraping of 
the output. I noticed that no buffers are freed when csharp is responsible for 
releasing, but all the buffers are freed when nanoarrow is (and presumably 
other implementations too, since no memory leaks are reported for those).
   
   ```
   #>    exporting importing                 file batch within_batch_id         
op
   #> 1  nanoarrow        C# primitive_zerolength     0               1 
reallocate
   #> 2  nanoarrow        C# primitive_zerolength     0               2 
reallocate
   #> 3  nanoarrow        C# primitive_zerolength     0               3 
reallocate
   #> 4  nanoarrow        C# primitive_zerolength     0               4 
reallocate
   #> 5  nanoarrow nanoarrow primitive_zerolength     0               1 
reallocate
   #> 6  nanoarrow nanoarrow primitive_zerolength     0               2 
reallocate
   #> 7  nanoarrow nanoarrow primitive_zerolength     0               3 
reallocate
   #> 8  nanoarrow nanoarrow primitive_zerolength     0               4 
reallocate
   #> 9  nanoarrow nanoarrow primitive_zerolength     0               5 
reallocate
   #> 10 nanoarrow nanoarrow primitive_zerolength     0               6 
reallocate
   #> 11 nanoarrow nanoarrow primitive_zerolength     0               7 
reallocate
   #> 12 nanoarrow nanoarrow primitive_zerolength     0               8 
reallocate
   #> 13 nanoarrow nanoarrow primitive_zerolength     0              53       
free
   #> 14 nanoarrow nanoarrow primitive_zerolength     0              56       
free
   #> 15 nanoarrow nanoarrow primitive_zerolength     0              59       
free
   #> 16 nanoarrow nanoarrow primitive_zerolength     0              62       
free
   #> 17 nanoarrow nanoarrow primitive_zerolength     0             116       
free
   #> 18 nanoarrow nanoarrow primitive_zerolength     0             119       
free
   #> 19 nanoarrow nanoarrow primitive_zerolength     0             122       
free
   #> 20 nanoarrow nanoarrow primitive_zerolength     0             125       
free
   ```
   
   I *think* that they show that C# is *not* calling the release callback for 
zero-length arrays that it imports (at least in the integration test). I 
*think* that this doesn't show up for other exporters that track memory (e.g., 
C++) because *maybe* those implementations do not allocate any buffers for a 
zero-length string (I haven't verified this yet).
   
   Is there a specific place in the csharp code where I could start poking to 
verify this? I couldn't spot anything obvious from browsing the 
`ImportedArrowArray` but I am also 0% fluent in C# 😬 .
   
   ### Component(s)
   
   C#, Integration


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to