Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/src/arrow/python/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ PyBuffer::PyBuffer(PyObject* obj) : Buffer(nullptr, 0), obj_(nullptr) {
size_ = buffer->len;
capacity_ = buffer->len;
is_mutable_ = false;
Py_INCREF(obj_);
}
}

Expand Down
27 changes: 26 additions & 1 deletion python/scripts/test_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
import memory_profiler
import gc
import io


def leak():
Expand All @@ -32,4 +33,28 @@ def leak():
table.to_pandas()
gc.collect()

leak()
# leak()


def leak2():
data = [pa.array(np.concatenate([np.random.randn(100000)] * 10))]
table = pa.Table.from_arrays(data, ['foo'])
while True:
print('calling to_pandas')
print('memory_usage: {0}'.format(memory_profiler.memory_usage()))
df = table.to_pandas()

batch = pa.RecordBatch.from_pandas(df)

sink = io.BytesIO()
writer = pa.RecordBatchFileWriter(sink, batch.schema)
writer.write_batch(batch)
writer.close()

buf_reader = pa.BufferReader(sink.getvalue())
reader = pa.open_file(buf_reader)
reader.read_all()

gc.collect()

leak2()