Closed GoogleCodeExporter closed 8 years ago
I observe no memory leak at all when running this loop:
normalImage = cvLoadImage("lena.jpg");
for (int i = 0; i < 1000000; i++) {
someFunction();
}
where "lena.jpg" is a file that comes with OpenCV.
My Java:
OpenJDK Runtime Environment (IcedTea6 1.9.10) (fedora-55.1.9.10.fc14-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
Original comment by samuel.a...@gmail.com
on 29 Dec 2011 at 10:10
[deleted comment]
I was able to reproduce memory leak with following code. I am not sure if this
is expected behavior of JNI but using cvReleaseImage() fixes the problem.
Assigned variables within functions are not garbage collected.
public static void main(String[] args) {
for (int i = 0; i < 100000; i++) {
IplImage someImage = getImage(); // causes memory leak
// cvReleaseImage(someImage); // fixes memory leak
}
}
public static IplImage getImage() {
// IplImage normalImage = cvLoadImage("bg.bmp");
IplImage normalImage = cvCreateImage(cvSize(320, 240), IPL_DEPTH_8U, 3);
return normalImage;
}
Original comment by vlada...@gmail.com
on 14 Jan 2012 at 1:48
Yes that's normal, cvCreateImage() is nothing more than a normal C function.
Use the IplImage.create() factory method if you want garbage collection
behavior.
Original comment by samuel.a...@gmail.com
on 24 Jan 2012 at 11:00
Judging by the lack of feedback, I assume the issue has been resolved. Please
let me know if this is not the case.
Original comment by samuel.a...@gmail.com
on 19 Feb 2012 at 4:47
Original issue reported on code.google.com by
kdo...@gmail.com
on 13 Dec 2011 at 11:09