View Single Post
  #20   Spotlight this post!  
Unread 07-03-2012, 15:26
misko misko is offline
Registered User
FRC #0852
 
Join Date: Dec 2009
Location: California
Posts: 22
misko is an unknown quantity at this point
Re: SmartDashboard Crashing

I'm not sure it's a memory leak. I got some additional debug information, but I'm no java expert. I think the problem is below. What happens if cam.getNewImage returns NULL? Because based on the traceback I got that's what appears to be happening. I don't see an explicit check to validate that we got an image (but I haven't looked at the getNewImage code), but if it does get a NULL, then it explains the access violation.
Any java coders out there that can help?

try {
image = cam.getNewImage(5.0);

if (image instanceof WPIColorImage) {
drawnImage = processImage((WPIColorImage) image).getBufferedImage();
SwingUtilities.invokeLater(draw);

} else if (image instanceof WPIGrayscaleImage) {
drawnImage = processImage((WPIGrayscaleImage) image).getBufferedImage();
SwingUtilities.invokeLater(draw);
}
} catch (final Exception e) {
e.printStackTrace();
cam.dispose();
cam = null;
drawnImage = null;
SwingUtilities.invokeLater(draw);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
}