diff --git a/python/perspective/perspective/src/table.cpp b/python/perspective/perspective/src/table.cpp
index a8fe5bd0d0..3af60300ed 100644
--- a/python/perspective/perspective/src/table.cpp
+++ b/python/perspective/perspective/src/table.cpp
@@ -34,6 +34,7 @@ std::shared_ptr
make_table_py(t_val table, t_data_accessor accessor,
std::shared_ptr tbl;
std::shared_ptr gnode;
std::uint32_t offset;
+ void* ptr = nullptr;
// If the Table has already been created, use it
if (table_initialized) {
@@ -59,7 +60,7 @@ std::shared_ptr make_table_py(t_val table, t_data_accessor accessor,
if (is_arrow && !is_delete) {
py::bytes bytes = accessor.cast();
std::int32_t size = bytes.attr("__len__")().cast();
- void * ptr = malloc(size);
+ ptr = malloc(size);
std::memcpy(ptr, bytes.cast().c_str(), size);
{
PerspectiveScopedGILRelease acquire(pool->get_event_loop_thread_id());
@@ -193,6 +194,10 @@ std::shared_ptr make_table_py(t_val table, t_data_accessor accessor,
_fill_data(data_table, accessor, input_schema, index, offset, limit, is_update);
}
+ if (is_arrow) {
+ free(ptr);
+ }
+
// calculate offset, limit, and set the gnode
tbl->init(data_table, row_count, op, port_id);