-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cv2.MinMaxLoc causes Memory leak #1642
Comments
(日本の方とお見受けして日本語で回答します。) 私の環境ではリークらしき状況は確認できませんでした。
一つだけ思い当るフシとして、以下のようなコードをお試しいただけますか。 for (long i = 0; i < 1000000000; i++)
{
double[] numbers = new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
using (Mat mat1 = Mat.FromArray(numbers))
using (InputArray ia1 = mat1)
{
Cv2.MinMaxLoc(ia1, out _, out _, out _, out _);
}
}
|
@shimat 様 ※ところでこの件とは関係ないかもしれませんが、下記のようなコード(Mat同士のDotやCross)でもメモリリークが発生するように見えます。 double[] arr1 = new double[3] { 0, 1, 2 };
double[] arr2 = new double[3] { 1, 2, 3 };
Mat mat1, mat2;
mat1 = Mat.FromArray(arr1);
mat2 = Mat.FromArray(arr2);
for (int i = 0; i < 100000000; i++)
{
// using (Mat val = mat1.Dot(mat2))
using (Mat val = mat1.Cross(mat2))
{
}
} 解決策をご存知でしたら、教えていただけますと幸いです。 |
DotやCrossは引数としてやはり
前のコメントのように using で全て取り扱うのが最も確実ですが、ほかに TorchSharp でのこちらのドキュメントは、だいたい事情はOpenCvSharpとも共通しており参考になるかもしれません。https://github.com/dotnet/TorchSharp/blob/main/docfx/articles/memory.md#technique-1-automatic-disposal-via-garbage-collection |
承知しました。 |
Summary of your issue
It looks like that the below code causes Memory leak.
I tried ResourcesTracker, but does not work well for this problem.
Environment
What did you do when you faced the problem?
Example code:
Output:
Increase the Memory usage...
Do you have any ideas to solve this?
The text was updated successfully, but these errors were encountered: