Go to Post Let’s not scare the newbies away, let’s welcome them and help them. - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Spotlight this post!  
Unread 02-27-2015, 12:17 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: No robot code after running for a while (Java VM ran out of memory)

Quote:
Originally Posted by Ether View Post
Thanks for the detailed explanation.

The question still remains I guess: why did that "problematic allocation" cause the code to crash after an extended period of running?

It would be useful to understand exactly what's going on. Such understanding could provide Java teams with some guidance concerning memory allocation.

Java gurus?


In our previous C++ implementation, the main robot thread will free the image frame once it's done with it. But in Java, there is no "delete" object. Java relies on the garbage collector to automatically reclaim unused memory. I am not an expert in Java but my understanding is that garbage collection is a relatively expensive operation. It needs to scan references to objects to make sure an object has no reference before it can be reclaimed. Because of the expensive nature of the operation, garbage collector tends to run only when memory is running low (below a certain threshold). In our case, we are allocating image frame at processing rate (could be as fast as the video frame rate). I am guessing the garbage collector was not able to catch up by reclaiming enough memory for the allocation so the Java VM simply run out of memory and crashed.
In my personal opinion, I always don't like the fact that Java takes away the ability for programmers to explicitly free memory. Garbage collector to auto reclaim memory is nice but it doesn't have to take away the delete operator. I know why they did it but I don't agree with it.
__________________
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:04 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi