From fe71baba07f4b582b5ec2e36ad50301f1186ca34 Mon Sep 17 00:00:00 2001 From: MithunR Date: Thu, 13 Jan 2022 06:11:42 -0800 Subject: [PATCH] Fix memory leaks in JNI native code. (#10029) This commit fixes a couple of minor, host-side memory leaks in the JNI native code. The objects in question did not need to go on the heap. They have, in this commit, been switched to stack objects. Authors: - MithunR (https://github.com/mythrocks) Approvers: - Jason Lowe (https://github.com/jlowe) URL: https://github.com/rapidsai/cudf/pull/10029 --- java/src/main/native/src/ColumnVectorJni.cpp | 4 ++-- java/src/main/native/src/ColumnViewJni.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/src/main/native/src/ColumnVectorJni.cpp b/java/src/main/native/src/ColumnVectorJni.cpp index e61ab8444d1..b0286f9ac27 100644 --- a/java/src/main/native/src/ColumnVectorJni.cpp +++ b/java/src/main/native/src/ColumnVectorJni.cpp @@ -359,10 +359,10 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobje std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); - cudf::table_view *input_table = new cudf::table_view(column_views); + cudf::table_view input_table{column_views}; std::unique_ptr result = - cudf::hash(*input_table, static_cast(hash_function_id), seed); + cudf::hash(input_table, static_cast(hash_function_id), seed); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index 73ea49c18d9..d2cc2ab7d1c 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1604,17 +1604,17 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); - cudf::table_view *input_table = new cudf::table_view(column_views); + cudf::table_view input_table{column_views}; cudf::binary_operator op = static_cast(bin_op); switch (op) { case cudf::binary_operator::BITWISE_AND: { - auto [new_bitmask, null_count] = cudf::bitmask_and(*input_table); + auto [new_bitmask, null_count] = cudf::bitmask_and(input_table); copy->set_null_mask(std::move(new_bitmask), null_count); break; } case cudf::binary_operator::BITWISE_OR: { - auto [new_bitmask, null_count] = cudf::bitmask_or(*input_table); + auto [new_bitmask, null_count] = cudf::bitmask_or(input_table); copy->set_null_mask(std::move(new_bitmask), null_count); break; }