Closed chenyexin2012 closed 11 months ago
Could you explain the advantage of the method you're proposing?
Mat mat = new Mat(new Size(3,3), CV_8U, Scalar.all(0));
// increase the reference count by 1
mat.retainReference();
// mat will be released
// it seems useless to call the retainReference method only one time
mat.releaseReference();
// i don't understand why it's designed like this
mat = new Mat(new Size(3,3), CV_8U, Scalar.all(0));
// call retainReference twice
mat.retainReference();
mat.retainReference();
// mat will not be released
mat.releaseReference();
Maybe what you're looking for is the close() method, which always deallocates?
If you're just looking for an explanation, I talk here a bit about the reasons why it's like that: https://groups.google.com/a/tensorflow.org/g/jvm/c/FyXjlFmmTJI/m/NeDG-OC6AQAJ
If you're just looking for an explanation, I talk here a bit about the reasons why it's like that: https://groups.google.com/a/tensorflow.org/g/jvm/c/FyXjlFmmTJI/m/NeDG-OC6AQAJ
I see, thank you!
when I only call the retain method once, the count value becomes 1, and then call the release method, (deallocator != null && count.decrementAndGet() <= 0) will be true, and the deallocate method will be executed. in this case, it seems useless to call the retain method only once
i think it's more suitable to use getAndDecrement method to instead decrementAndGet.