Looking at the source for NIVision I think the .free() will work if used in a finally block. When we tried it the first time it didn't end up in a finally block and the image was being used as a member variable.
The NIVision class is calling C libraries that allocate memory outside the JVM so the correct steps we need are (pseudo code):
- Image image;
- try
- allocate image - image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_ RGB, 0);
- use image - CameraServer.getInstance().setImage(image);
- finally
- free image - image.free();
Will repost when we understand better.