Skip to content

Commit

Permalink
Fix memory leaks in JNI native code. (#10029)
Browse files Browse the repository at this point in the history
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: #10029
  • Loading branch information
mythrocks authored Jan 13, 2022
1 parent 4950a7a commit fe71bab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions java/src/main/native/src/ColumnVectorJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cudf::column> result =
cudf::hash(*input_table, static_cast<cudf::hash_id>(hash_function_id), seed);
cudf::hash(input_table, static_cast<cudf::hash_id>(hash_function_id), seed);
return reinterpret_cast<jlong>(result.release());
}
CATCH_STD(env, 0);
Expand Down
8 changes: 4 additions & 4 deletions java/src/main/native/src/ColumnViewJni.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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<cudf::binary_operator>(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;
}
Expand Down

0 comments on commit fe71bab

Please sign in to comment.