Skip to content

Commit 2f29995

Browse files
committed
fixed Tensor memory leak.
1 parent 0f14ec0 commit 2f29995

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/TensorFlowNET.Core/Sessions/BaseSession.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ private unsafe NDArray[] _call_tf_sessionrun(KeyValuePair<TF_Output, Tensor>[] f
186186
var result = new NDArray[fetch_list.Length];
187187

188188
for (int i = 0; i < fetch_list.Length; i++)
189-
{
190189
result[i] = fetchValue(output_values[i]);
191-
}
190+
191+
for (int i = 0; i < feed_dict.Length; i++)
192+
feed_dict[i].Value.Dispose();
192193

193194
return result;
194195
}

src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private IntPtr Allocate(NDArray nd)
111111
// Free the original buffer and set flag
112112
Deallocator deallocator = (IntPtr values, IntPtr len, ref bool closure) =>
113113
{
114-
Marshal.FreeHGlobal(dotHandle);
114+
Marshal.FreeHGlobal(values);
115115
closure = true;
116116
};
117117

0 commit comments

Comments
 (0)