Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks in JNI native code. #10029

Merged
merged 2 commits into from
Jan 13, 2022
Merged
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
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(),
mythrocks marked this conversation as resolved.
Show resolved Hide resolved
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