Quote:
Originally Posted by pblankenbaker
I'm not really sure if calling free() is required on image objects (in Java you would hope that resources would be automatically freed by the garbage collector), I just know that our problem went away once we started invoking free().
Again, not sure if this is related to the problem you are seeing (I didn't see anything in your error messages about running out of memory), but it might be something to try.
Good luck.
|
We used to have a C++ library that has a vision target class. It allocates a frame buffer to process each camera image it receives. When we switched over to Java, we ported this class to Java. We thought since Java has a garbage collector, so we took out all the "free" calls in the code. It surprised us when we hit the "Java VM ran out of memory" exception. So the moral of the story is, although Java has a garbage collector that reclaims unused memory, it's an expensive operation and does not do well if a large number of memory allocations are required (i.e. the allocation out paced garbage collection). So it is possible to exhaust the Java memory pool. We ended up re-architected that part of the code and pre-allocated two frame buffers and doing ping-pong on only these two buffers. That took care of the "out-of-memory" exception.