[
https://issues.apache.org/jira/browse/ARROW-2375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16423474#comment-16423474
]
ASF GitHub Bot commented on ARROW-2375:
---------------------------------------
xhochy closed pull request #1821: ARROW-2375: [Rust] Implement Drop for Buffer
so memory is released
URL: https://github.com/apache/arrow/pull/1821
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/rust/src/buffer.rs b/rust/src/buffer.rs
index f70e0e2cd..bf82d1f33 100644
--- a/rust/src/buffer.rs
+++ b/rust/src/buffer.rs
@@ -56,6 +56,12 @@ impl<T> Buffer<T> {
}
}
+impl<T> Drop for Buffer<T> {
+ fn drop(&mut self) {
+ mem::drop(self.data)
+ }
+}
+
macro_rules! array_from_primitive {
($DT:ty) => {
impl From<Vec<$DT>> for Buffer<$DT> {
@@ -93,6 +99,7 @@ array_from_primitive!(i64);
#[cfg(test)]
mod tests {
use super::*;
+
#[test]
fn test_buffer_i32() {
let b: Buffer<i32> = Buffer::from(vec![1, 2, 3, 4, 5]);
diff --git a/rust/src/memory.rs b/rust/src/memory.rs
index 5cecaa13d..db527ab34 100644
--- a/rust/src/memory.rs
+++ b/rust/src/memory.rs
@@ -39,7 +39,12 @@ mod tests {
#[test]
fn test_allocate() {
- let _ = allocate_aligned(32 * 1024).unwrap();
+ for _ in 0 .. 10 {
+ let p = allocate_aligned(1024).unwrap();
+ // make sure this is 64-byte aligned
+ assert_eq!(0, (p as usize) % 64);
+ }
+
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Rust] Buffer should release memory when dropped
> ------------------------------------------------
>
> Key: ARROW-2375
> URL: https://issues.apache.org/jira/browse/ARROW-2375
> Project: Apache Arrow
> Issue Type: Bug
> Components: Rust
> Reporter: Andy Grove
> Assignee: Andy Grove
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.10.0
>
>
> The initial PR failed to implement Drop for Buffer<T> meaning that memory is
> never deallocated.
> Here is a PR to resolve this: https://github.com/apache/arrow/pull/1821
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)