|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Java, WPI, Image Processing, and OMG I got a memory leak...
I created the targeting code for our robot today. Everything was working great until about 20 seconds in ... WHAM! Out of memory... I'm pretty sure I freed both the BinaryImage I used and the ColorImage I used correctly. Please don't tell me this is a memory leak in the WPILibJ because targeting will be impossible since all the code is precompiled for Java and would be extra-tricky to change.
|
|
#2
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
You may not be running into a memory leak, but instead memory fragmentation. To minimize the number of (re)allocations done, you can try something like this:
Code:
// Inside the class, outside of any methods Image image = new RGBImage(); BinaryImage bin = new BinaryImage(); Code:
camera.getImage(image); NIVision.colorThreshold(bin.image, image.image, ... ); // Other processing ... |
|
#3
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
Thank you for a positive response, Ill try this when Im with the robot next. I am curious though, is this how you do your targeting?
Last edited by Team3266Spencer : 02-14-2013 at 10:06 AM. |
|
#4
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
I used that technique last year to minimize memory consumption, but this year our tracking software is running as a SmartDashboard extension.
|
|
#5
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
Just a notice that the SmartDashboard v1.05 revision is up as of a few hours ago, and it solves several issues with the vision plugin.
I'm not sure if that would help you (it sounds like you're doing it robot-side?) but it may help others. |
|
#6
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
I don't want the delay of the data transfer, but thank you for that wonderful news. I hope it fixes the SmartDashboard crashing bug.
|
|
#7
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
What do I do about the exception handling?
|
|
#8
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
try{
// }catch(SomethingException ex){ ex.printStackTrace(); } |
|
#9
|
||||
|
||||
|
Re: Java, WPI, Image Processing, and OMG I got a memory leak...
You can't put try statements outside of a method. I found that simply creating the image objects outside of a method fixed my memory issues, I did not need to initialize them outside the method or call methods from NIVision. Thank you for the help Joe.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|