N4 - Adjusting NRE memory pools on N4 Jace Niagara Runtime Environment

Problem:
The NRE memory allocations in an Niagara 4 JACE can be manually adjusted by the user and these values greatly affect the operation of the system as a whole. Users need a better understanding of the 'Configure NRE Memory Pools' settings and how they affect one another. Incorrect memory allocations could prevent the station from starting or could cause the station to fail and restart.

Solution:


Niagara4 JACE NRE memory can be manually adjusted. The 'Configure NRE Memory Pools' tool is reached via Platform Administration. 
NOTE- Prior to release 4.2 the 'System Reserve'  was not visible. Instead you changed the 'System Reserve' by increasing or decreasing the 'Meta Space' value.

There are descriptions located in the dialog window of the tool. Below are more notes regarding the four available settings.

System Reserve - A best practice is to set the System Reserve to a value of 3 - 5 MB. This ensures that the system will always have memory in reserve in case some process needs to spawn a new thread, etc. This will take memory away from the Heap, but will better insure system stability.
 
Heap Space - This is where the station is running. As your program grows it will require more memory (heap). Note that to increase the station's heap space you decrease the Meta Space (the space that holds all the JAR files loaded. Jar files hold the java classes). Altering the Heap Space affects the Meta Space.
 
Meta Space - In Java8, Meta Space replaced Perm Gen. This is the space that holds all the Java classes that get loaded from all the modules. As you install more drivers, this requires more Jar files be loaded. The Jar files are holding the classes for the drivers. So, the act of installing more drivers typically requires the Meta Space to be increased. Remember that increasing Meta Space reduces the Heap Space. So you are balancing increasing the size of the station (which might require more jar files if new classes need to be loaded due to a driver install) and also managing the Meta Space. Note that Meta Space can be increased by decreasing the Heap Space or decreasing Ram Disk Size (or both). Just remember that altering Meta Space affects the Heap space.
 
Ram Disk - Holds histories and alarms. As with AX, you always should limit how much data you hold on the Jace in regards to histories and alarms. Store a few days worth of data and plan to archive to the supervisor. Altering Ram Disk affects the Meta Space size.
 
Code Cache - The way Java functions is with a JIT (Just-In-Time compiler). As Java is executing classes it compiles stuff on the fly. It uses this cache to save code that has been compiled so it doesn't need to compile it again on the fly. It determines the code that is being used often and caches that. But there is only so much memory available to cache code, so it is still using the JIT as the station is running. If you let JAVA cache lots of code the station is going to run faster, but you risk robbing too much memory from the HEAP and Meta spaces, hence not being able to run the station at all. Remember that when you adjust the Code Cache you affect the Ram Disk space.
 

Viewing current resources can be accomplished using 'Platform Diagnostics' from the 'Spy' page (right click on station in Workbench tree and select 'Spy'). Click on 'Platform Diagnostics', then 'JMX Info'.

In conclusion, N4 is a very flexible platform and depending on how the station has been programmed, you might need to adjust the above settings.