fix memleak - #69
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ivanallen
commented
Nov 7, 2020
Emm... It's not really the same thing. defer is more general. |
ljn917
commented
Nov 7, 2020
via email
I am mostly neutral (though slightly negative) on the defer class here,
because it can be implemented using std::unique_ptr without too much
complication. However, I like defer as a general cleanup as in golang. …On Sat, Nov 7, 2020, 03:00 Allen ***@***.***> wrote:
Class defer seems to be duplicating the function of std::unique_ptr. I
don't know how @serizba <https://github.com/serizba> feels about it.
Emm... It's not really the same thing. defer is more general.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#69 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALDTHWKZDK4GO6SQK75NEDSOT5A3ANCNFSM4TNPMYCA>
.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
serizba
commented
Nov 12, 2020
I do not have a strong opinion on the topic either. I will accept the request if you both agree on it. If you think that just using |
ljn917
commented
Nov 22, 2020
@ivanallen I am sorry that I didn't get much time to test this, my apologies. The other @serizba I think this is good to go. Although gcc's leak sanitizer still shows leaks in libcuda.so, I think it is false positive. If you still prefer |
ivanallen
commented
Nov 23, 2020
I list the difference between
std::vector<TF_Tensor*> inp_val(inputs.size());
+ defer d([&inp_val]{
+ for (auto* tf_tensor : inp_val) TF_DeleteTensor(tf_tensor);
+ });
+ std::vecotr<std::unique_ptr<TF_Tenosr, decltype(&TF_DeleteTensor)>> inp_val_ptr;
std::vector<TF_Tensor*> inp_val(inputs.size());
//...for (...) {
// ...auto inp_tensor = TFE_TensorHandleResolve(std::get<1>(inputs[i]).tfe_handle.get(), context::get_status());
+ inp_val_ptr.emplace_back(inp_tensor, TF_DeleteTensor);
+ inp_val[i] = inp_tensor; // copy raw pointer to anther vector
}
//... |
I think @serizba should be the person to make the final decision here :) |
serizba
commented
Nov 24, 2020
Thanks for showing both options @ivanallen, Now I think that perhaps using |
ivanallen
left a comment
There was a problem hiding this comment.
New problems will be resolved in a new pull request.
Fix memory leak.