diff options
author | Derek Murray <mrry@google.com> | 2018-09-25 12:55:00 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-25 13:00:30 -0700 |
commit | 471e20a6738a326adeb0eef2d158b61bbfd23d6d (patch) | |
tree | bd3a7581d25f48f5aa481653cbb7f9cd3bdd2317 /tensorflow/compiler/jit | |
parent | b62cadc1513a73c1673094c9e35421c8a6c17645 (diff) |
Fix memory leaks of Var objects in the XlaCompileOnDemandOp and SnapshotResourceVariables function.
PiperOrigin-RevId: 214488033
Diffstat (limited to 'tensorflow/compiler/jit')
-rw-r--r-- | tensorflow/compiler/jit/xla_compile_on_demand_op.cc | 1 | ||||
-rw-r--r-- | tensorflow/compiler/jit/xla_launch_util.cc | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc index 3c160aefe5..b98c0cb028 100644 --- a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc +++ b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc @@ -34,6 +34,7 @@ std::map<int, OptionalTensor> GetVariables(OpKernelContext* ctx) { OptionalTensor& optional = variables[i]; optional.name = handle.name(); if (LookupResource(ctx, handle, &variable).ok()) { + core::ScopedUnref scoped_unref(variable); tf_shared_lock lock(*variable->mu()); optional.present = true; optional.value = *variable->tensor(); diff --git a/tensorflow/compiler/jit/xla_launch_util.cc b/tensorflow/compiler/jit/xla_launch_util.cc index f5c8bdd6ee..4f6fc4e068 100644 --- a/tensorflow/compiler/jit/xla_launch_util.cc +++ b/tensorflow/compiler/jit/xla_launch_util.cc @@ -49,6 +49,7 @@ std::map<int, OptionalTensor> SnapshotResourceVariables( ResourceHandle handle = HandleFromInput(ctx, i); OptionalTensor& tensor = snapshot[i]; if (LookupResource(ctx, handle, &variable).ok()) { + core::ScopedUnref scoped_unref(variable); tf_shared_lock lock(*variable->mu()); tensor.name = handle.name(); tensor.present = true; |