|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
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):
Will repost when we understand better. |
|
#2
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
Still crashing.
Here's the JVM version... Code:
gsmin@roboRIO-3932-FRC:/usr/local/frc/bin# /usr/local/frc/JRE/bin/java -version -XX:+PrintCommandLineFlag java version "1.8.0_06" Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23, profile compact2, headless) Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode) admin@roboRIO-3932-FRC:/usr/local/frc/bin# cd /usr/local/frc/JRE/bin admin@roboRIO-3932-FRC:/usr/local/frc/JRE/bin# ls java keytool rmid rmiregistry admin@roboRIO-3932-FRC:/usr/local/frc/JRE/bin# cd Code:
Mem: 176600K used, 75372K free, 0K shrd, 93K buff, 3067729088K cached CPU: 9% usr 12% sys 0% nic 76% idle 0% io 0% irq 0% sirq Load average: 2.22 2.15 2.30 4/290 8550 |
|
#3
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
Here is our latest and cleanest code with all the logic encapsulated in a single class. This still crashes the JVM...
Code:
public class CameraConfig {
private AxisCamera camera;
private String URL;
public CameraConfig(String URL){
this.URL = URL;
this.camera = new AxisCamera(this.URL);
camera.writeExposurePriority(50);
}
public void sendImage() {
Image image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
try {
camera.getImage(image);
CameraServer.getInstance().setImage(image);
} catch (Exception e) {
System.err.println("Failed to get image from camera");
System.err.println(e.getStackTrace());
} finally {
image.free();
}
}
public boolean exists() {
boolean flag = false;
Image image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
try {
camera.getImage(image);
flag = true;
}
catch (Exception e){
}
finally {
image.free();
}
return flag;
}
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|