Closed cike111 closed 1 week ago
Confirmed, Mat_Set will cause a memory leak even though manually dispose Mat, but every thing looks ok, not sure why...
@cike111 v1.0.10 and 2.0.0-dev.12 have been published, please update and try if it has been solved, if not please open this issue again.
@rainyl Your approach seems to have some effect, but it hasn't completely solved the problem.
@cike111 emmmmm..., alright, I suggest you to dispose it manually if you have to create mats in a loop, due to the limitation of dart GC (https://github.com/rainyl/opencv_dart/issues/64#issuecomment-2137342504), the attached native resources may not be freed timely, in the above example, change it to
test(){
CV.Mat grayMat = CV.Mat.zeros(
1000, 1000, CV.MatType.CV_8UC1);
int maxY = grayMat.rows - 1;
int maxX = grayMat.cols;
for (int y = maxY; y >= 0; y--) {
for (int x = 0; x < maxX; x++) {
grayMat.set<int>(0, 0, 30);
}
}
// add this line
grayMat.dispose();
}
If the problem still exists, then I have no more ideas too, and I have no apple devices so can't debug it, on my windows PC every thing is ok.
Describe the bug In iOS, if you call grayMat.set(y, x, grayLevel) every 2 seconds, it will cause the memory to continuously increase
To Reproduce![17186112505115](https://github.com/rainyl/opencv_dart/assets/23070090/b53cc96c-d9e1-4a6f-9556-4a9d488597b6)
pubspec.yaml code:
mian.dart