wangfenjin edited a comment on issue #1425: URL: https://github.com/apache/arrow-rs/issues/1425#issuecomment-1064974978
Let me put in another way. Let's say in Java you create an ArrowArray and import in this lib using try_from_raw API, and this API clone the ArrowArray, which means **_there will be two struct point to the same data_**, one is in Jave another is in rust. Then 1. If you free the pointer in Java(which by design will also free all the data it point to), it will be seg fault in rust if you try to access it; 2. And you just can't hold the Java's pointer until it's used/freed by rust, because you don't when it will be used. So it's a memory leak. I bet currently in your Java program there is memory leak because of these. I think the way to fix your issue is to change the Java API design, to let other language like rust to pass in a FFI_ArrowArray::empty() struct pointer, and populate data into this struct, and let rust handle the memory itself. That's why I say "the one who allocate it should free it," -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org