Go to Post If you promote not only the growth of your own team but of other teams at other schools you are successful. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 27-01-2015, 18:04
magnets's Avatar
magnets magnets is offline
Registered User
no team
 
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
magnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond repute
RoboRIO won't let us use more than 50mb of RAM?

Our team plans to use vision to help us locate and align with the yellow totes. We plan to do run our image processing on the roboRIO, as we should only need to do analysis of 6 frames during autonomous mode. For time-saving purposes, we like to keep lots of information in the roboRIO's RAM for debugging/frame by frame playback. I was running a ported version of the vision stuff a student had made with the cRIO, but I am constantly getting out of memory errors.

We're using Java.
Here's what I've put together so far:
The roboRIO has 256 mb of RAM, twice as much as the cRIO.

When the user code has been killed, background processes use 151 mb of the 256 mb. I don't know why this is so much (I guess linux isn't as small as it once was), but it's not unreasonable, considering there's networking, communications, web server, ftp, ssh....

This leaves 105 mb for the user code. Running an empty iterative robot project brings this down to 93 mb free. Why the controller needs 12 mb of memory to call the disabledPeriodic method is beyond me, but still, not too unreasonable.

93 mb is still a decent amount RAM. However, when I get to 60 mb of free memory, the java program is terminated.

This seems a little silly, as the code once ran on a cRIO and didn't get an out of memory error because the cRIO let me get down to 4 mb of free RAM. I'm likely doing something stupid, but I don't know what I'm doing. Any suggestions on how to get to the extra 60 mb of RAM?
Reply With Quote
  #2   Spotlight this post!  
Unread 27-01-2015, 18:10
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,076
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: RoboRIO won't let us use more than 50mb of RAM?

Sounds like Java isn't configured to use a very large heap by default. There should be a way to pass an -Xmx option to the JVM, but I'm not sure where exactly to put it in the current RoboRIO setup.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-01-2015, 18:52
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: RoboRIO won't let us use more than 50mb of RAM?

I ran into this today too, and I originally thought exactly what Jared thought, that the JVM wasn't configured to let the java program use very much memory, but the error message states that "there is not enough memory for the Java Runtime Environment to continue".

I checked the error log, which confirmed that the system ran out of memory, not that the heap size was too small.

Unlike magnets, I got down to 46Mb free on the Driver Station before a crash occured. Interestingly, after the crash, the Driver Station window became maximized, which let me see cool debugging information about the Driver Station.

The error logs records the output of /proc/meminfo. Perhaps somebody with more linux experience could explain what's happening.

Code:
---------------  S Y S T E M  ---------------

OS:Linux
uname:Linux 3.2.35-rt52-2.0.0f0 #1 SMP PREEMPT RT Tue Jun 3 20:49:19 CDT 2014 armv7l
libc:glibc 2.17 NPTL 2.17 
rlimit: STACK 256k, CORE 2048k, NPROC 1852, NOFILE 4096, AS infinity
load average:2.34 0.80 0.28

/proc/meminfo:
MemTotal:         237120 kB
MemFree:           46784 kB
Buffers:               0 kB
Cached:            68316 kB
SwapCached:            0 kB
Active:            97544 kB
Inactive:          34200 kB
Active(anon):      85224 kB
Inactive(anon):     1768 kB
Active(file):      12320 kB
Inactive(file):    32432 kB
Unevictable:       28304 kB
Mlocked:           28356 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         91820 kB
Mapped:            46288 kB
Shmem:              2432 kB
Slab:              20768 kB
SReclaimable:       9904 kB
SUnreclaim:        10864 kB
KernelStack:        2120 kB
PageTables:         1372 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      187324 kB
Committed_AS:     173552 kB
VmallocTotal:     516096 kB
VmallocUsed:       19928 kB
VmallocChunk:     491452 kB
The problem isn't a too small heap size, but that the JVM isn't able to use 46mb of RAM.

Last edited by Jared : 27-01-2015 at 18:55.
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2015, 18:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: RoboRIO won't let us use more than 50mb of RAM?

Quote:
Originally Posted by Jared View Post
not that the stack size was too small
Jared said heap, not stack. Memory is allocated from the heap.

[edit] I see you corrected that...

Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2015, 21:51
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,560
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: RoboRIO won't let us use more than 50mb of RAM?

I can confirm that increasing the heap with -Xmx does not allow the user to allocate more memory. I did confirm that setting the maximum heap to a smaller value causes a different error

Code:
Unhandled exception: java.lang.OutOfMemoryError: Java heap space at [org.usfirst.frc.team8330.robot.Robot.disabledPeriodic(Robot.java:45), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:102), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:234)]
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2015, 09:29
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: RoboRIO won't let us use more than 50mb of RAM?

Quote:
Originally Posted by Ether View Post
Jared said heap, not stack. Memory is allocated from the heap.

[edit] I see you corrected that...

Note that you do not have to worry much about stacks space for user programs in Linux. Your threads have huge allocated virtual stack spaces (like 2MB) and the required physical pages for the stack are committed as needed. So, in effect, your stacks start at 4K (the size of one page) and grow into the size required (within reason).

HTH
__________________
Fast, cheap or working - pick any two!
Reply With Quote
  #7   Spotlight this post!  
Unread 27-01-2015, 18:52
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: RoboRIO won't let us use more than 50mb of RAM?

You should be able to add arguments be editing "WPILIB_DIR/java/current/ant/robotCommand". I'm pretty sure this file is uploaded every time code is deployed. Also, keep in mind that this file will be overwritten when WPILib is updated.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #8   Spotlight this post!  
Unread 31-01-2015, 09:25
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: RoboRIO won't let us use more than 50mb of RAM?

Quote:
Originally Posted by magnets View Post
When the user code has been killed, background processes use 151 mb of the 256 mb. I don't know why this is so much (I guess linux isn't as small as it once was), but it's not unreasonable, considering there's networking, communications, web server, ftp, ssh....
Note that is it difficult to get a number for free memory with Linux. The kernel will increase the amount of memory it uses for file and network I/O when physical pages are available. But as more pages are requested from user space the kernel will back off and release memory.

Also, in user space, Linux will allow one to allocate MUCH more memory than actually exists. This is called "lazy allocation". The maps between the virtual pages allocated and the physical pages are only made when you write to a page (page by page).

HTH
__________________
Fast, cheap or working - pick any two!
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 07:06.

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