Comments (17)
I have also read the source code from javacv/opencv_highgui.
It seems the jni wrapper directly called the OpenCV's original code.
Probably it's a problem with the interface to the original C++ code. This is
the reason why we only observe the global memory leak but not for the running
Java thread.
Original comment by [email protected]
on 21 Oct 2011 at 12:33
from javacv.
I am seeing the same problem. in my case, I load the image via
IplImage.createFrom(java.awt.image.BufferedImage)
Original comment by [email protected]
on 21 Oct 2011 at 1:52
from javacv.
oh, great. Actually I have tried to copy from BufferedImage one pixel by one
pixel to the IplImage.
Now the problem has gone. At least, when java program terminates, the global
memory will be freed.
Thank you again.
Original comment by [email protected]
on 21 Oct 2011 at 2:43
from javacv.
Yes, first things first, this may very well be a problem inside OpenCV. Could
you try to run this cvLoadImage()/cvReleaseImage() loop in a C/C++ program and
see what that gives? Thank you
BTW, we can also use IplImage.copyFrom() to copy from a BufferedImage.
Original comment by [email protected]
on 21 Oct 2011 at 6:22
from javacv.
I didn't try that. But I used OpenCV in C++ 4 years ago, no problem with that.
And Also don't remember anyone report that bug in the group.
I guess for JavaCV, we should recommend people use IplImage.copyFrom for
current version.
Original comment by [email protected]
on 21 Oct 2011 at 6:27
from javacv.
[deleted comment]
from javacv.
They changed most of the code (for the worse IMO) since OpenCV 2.0, so it would
NOT surprise me to see issues like that, especially in the "deprecated" C
API... ah well. But then again, it may be JavaCV for some reason. Let me know
if you test it in C/C++, thanks.
Original comment by [email protected]
on 21 Oct 2011 at 6:33
from javacv.
I will try the C/C++ test. BTW, in my app I am using HPROF and noticing a huge
number of JNI global references building up over time (like almost 2 million).
Original comment by [email protected]
on 24 Oct 2011 at 5:33
from javacv.
well, it seems that OpenCV didn't fix the problem of cvloadimage in C++.
Instead we can use CVVimage:load.
Regarding my question, in javacv, I use iplimage.createfrom, there is still
memory leak accumulated. It's really strange. For 20 test images, the memory
will be released and back to original level after the program terminates. When
I run it on 60000 images, it will occupy 10 G memory finally and not release
the memory even after the program terminates.
Original comment by [email protected]
on 24 Oct 2011 at 6:54
from javacv.
I have just tried that cvLoadImage()/cvReleaseImage() loop in both C/C++ and
Java here and I get no memory leak at all...
C/C++:
int main(int argc, const char *argv[]) {
for (int i = 0; i < 1000000; i++) {
IplImage *image = cvLoadImage(argv[1]);
cvReleaseImage(&image);
}
}
Java:
public static void main(String[] args) {
for (int i = 0; i < 1000000; i++) {
IplImage image = cvLoadImage(args[0]);
cvReleaseImage(image);
image = null;
System.gc();
}
}
using both lena.jpg and box_in_scene.png image files that come with OpenCV, no
problem at all.
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)
and OpenCV 2.3.1 and JavaCV 2011-10-01
Let me know if you have more information that may be relevant. It seems to work
fine here.
Original comment by [email protected]
on 28 Oct 2011 at 2:38
from javacv.
I have memory leaks working with IplImage.create and BufferedImages, and a
strange crash that always happens the 3rd time I call IplImage.create.
I attach my testsuite which isolates the issue as much as possible.
Original comment by [email protected]
on 2 Nov 2011 at 3:48
Attachments:
from javacv.
the.duckman, after removing the incorrect calls to `cvReleaseImage()`, the code
you posted works just fine for me on the `lena.jpg` sample image file that
comes with OpenCV... Do you still have issues after removing the calls to
`cvReleaseImage()`?
Original comment by [email protected]
on 4 Nov 2011 at 4:39
from javacv.
Cheers Samuel, sorry to take so long to get back to you.
It works (but causes a memory leak), I don't follow why the calls (line 156,
158) are incorrect. Can you elaborate a bit for me please?
Original comment by [email protected]
on 10 Nov 2011 at 3:20
from javacv.
cvReleaseImage() is just a normal function, it does not cancel the
PhantomReference inside Pointer as set by IplImage.create() or
IplImage.createFrom(). We need to call IplImage.release() for an IplImage image
allocated that way, when we want memory to be deallocated "right now" that is.
Otherwise, the garbage collector will deallocate memory, eventually, possibly
not before the program terminates though...
Original comment by [email protected]
on 11 Nov 2011 at 3:47
from javacv.
Thankyou your advice was most helpfull. I have use IplImage.release() and all
issues were resolved.
-dm
Original comment by [email protected]
on 11 Nov 2011 at 9:07
from javacv.
So, is everything alright? Since I am unable to reproduce the problem, I am
marking as invalid, but please let me know if you still have some issue, thank
you.
Original comment by [email protected]
on 8 Jan 2012 at 3:43
- Changed state: Invalid
from javacv.
I run some pretty heavy unit tests on Win64. Currently able to process very
large quantities of data without any memory leak issues.
cheers.
-dm
Original comment by [email protected]
on 8 Jan 2012 at 3:52
from javacv.
Related Issues (20)
- FacePreview: ClassNotFoundException - java.awt.image.BufferedImage HOT 4
- parameters for cvmat method? HOT 5
- ObjectFinder in Adroid HOT 7
- FacePreview using new OpenCV API HOT 3
- SURF Detect "bad allocation" Error HOT 10
- How to install? UnsatisfiedLinkError jniopencv_core36577.dll HOT 7
- Demo: java.lang.UnsatisfiedLinkError - Reason: image not found HOT 13
- cvFindContours different results HOT 2
- cannot run javacv example, ClassNotFoundException (Mac OS X) HOT 13
- ChamferMatching HOT 3
- Flann radiusSearch, knnSearch HOT 3
- Unable to use JavaCV in Matlab R2011b HOT 9
- javacv throws java.lang.UnsatisfiedLinkError HOT 3
- Invalid Memory Access using FloatPointer and PointVectorVector (chamerMatching()) HOT 1
- Getting Linker Error HOT 2
- Issue with javacv implementation of HOG descriptor HOT 10
- Running the sample facepreview of JavaCV on Android with eclipse + Windows xp HOT 7
- Insufficient memory HOT 2
- cvGoodFeaturesToTrack issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javacv.