Go to Post Dean's never ending fountain of denim. - kjolana1124 [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2012, 20:02
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
100 threads then robot code gets terminated

If i spawn 100 threads, even though only 2 is active at all times, the robot code get terminated.

Why is this happening? And anyone know what the work around is?
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2012, 20:08
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: 100 threads then robot code gets terminated

Quote:
Originally Posted by shuhao View Post
And anyone know what the work around is?
Don't spawn 100 threads?
Reply With Quote
  #3   Spotlight this post!  
Unread 16-02-2012, 00:42
Zholl Zholl is offline
Registered User
AKA: Chris Sherwood
FRC #2996 (Cougars Gone Wired)
Team Role: Alumni
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Colorado Springs
Posts: 267
Zholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to beholdZholl is a splendid one to behold
Re: 100 threads then robot code gets terminated

Quote:
Originally Posted by RufflesRidge View Post
Don't spawn 100 threads?
I would have to agree here. Granted, I don't have much experience in Java, but my experience with other languages has been that if you have too many simultaneous threads of execution, the program slows down until the whole thing times out and crashes
Reply With Quote
  #4   Spotlight this post!  
Unread 16-02-2012, 08:31
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: 100 threads then robot code gets terminated

Quote:
Originally Posted by Zholl View Post
I would have to agree here. Granted, I don't have much experience in Java, but my experience with other languages has been that if you have too many simultaneous threads of execution, the program slows down until the whole thing times out and crashes
Yes that would even happen on non cRio applications such as a game on a computer... Why would you want 100 threads??
Reply With Quote
  #5   Spotlight this post!  
Unread 16-02-2012, 12:03
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
I don't have 100 active threads. I just spawned that many over Time. The Max active thread count I have is 2..
Reply With Quote
  #6   Spotlight this post!  
Unread 16-02-2012, 12:21
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: 100 threads then robot code gets terminated

What output is reported? Can you try to print out the amount of free Java heap occasionally (Runtime.getRuntime().freeMemory())?

You can also check the number of currently executing threads (including those that are waiting for something), by calling Thread.activeCount().
Reply With Quote
  #7   Spotlight this post!  
Unread 16-02-2012, 21:39
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Ill do the memory count tomorrow. Active thread is 2, as I've been trying to say...
Reply With Quote
  #8   Spotlight this post!  
Unread 16-02-2012, 23:48
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,169
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: 100 threads then robot code gets terminated

The operating system on the cRIO is vxWorks. The algorithm to select the next task/thread to run is constant order, in other words it doesn't care how many threads/tasks exist. My guess is that you are exhausting main memory somehow. What do all your threads do? It is hard to see the tulity of 100 threads on a FIRST robot.


HTH
__________________
Fast, cheap or working - pick any two!
Reply With Quote
  #9   Spotlight this post!  
Unread 17-02-2012, 08:05
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
.. again, the 100 threads are NOT concurrent. It is spawned during the life time of the operation ...
Reply With Quote
  #10   Spotlight this post!  
Unread 17-02-2012, 08:41
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: 100 threads then robot code gets terminated

I'm not that familiar with the Java VM implementation, but I assume it is stack based, like C and C++. Each thread is given its own stack along with other allocations for managing the thread resources. On some OSes that is not too big initially, but they have lots of VM room to grow into. On other OSes, they preallocate lots of stack for each thread. If your stack was 1MByte, then you would run the VM out of memory way before 100.

LabVIEW works around this by having a thread pool and generating its code to not be stack based, but be frame based. That allows it to have hundreds of parallel tasks without having hundreds of threads. But if your OS can handle hundreds of threads, you change a config and tell it to use that many. By default, it has four per processor per priority which are allocated as priorities are added.

On the DS, flip to the new Charts page and run your program. On the far right side are three numbers for free disk, RAM, and largest RAM. If the RAM is constantly dropping, you are hoarding or leaking memory. If the crash takes place about the time your RAM gets low, and especially when the Largest Block gets too small, then that explains it, right?

Greg McKaskle
Reply With Quote
  #11   Spotlight this post!  
Unread 17-02-2012, 08:50
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: 100 threads then robot code gets terminated

Quote:
Originally Posted by shuhao View Post
.. again, the 100 threads are NOT concurrent. It is spawned during the life time of the operation ...
Then kill the old threads!
Reply With Quote
Reply


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 11:32.

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