Skip to Content
Niagara 4 Supervisors & WorkplacesHow to manage memory allocations for a Niagara 4 Web Supervisor

How to manage memory allocations for a Niagara 4 Web Supervisor

Proper memory allocation is crucial for Niagara 4 Web Supervisor performance. This guide covers how to configure, monitor, and optimise memory settings to ensure reliable operation and prevent out-of-memory errors.

Overview

Memory management for Niagara 4 Web Supervisor involves:

  • Java Heap Memory: Primary memory for Java Virtual Machine (JVM)
  • Native Memory: Memory for native libraries and system resources
  • Garbage Collection: Automatic memory management and cleanup
  • Memory Monitoring: Tracking memory usage and performance

Understanding Memory Architecture

Memory Components

Niagara Web Supervisor uses:

  • Heap Memory: Where Java objects are stored
  • Non-Heap Memory: Metaspace, code cache, native memory
  • System Memory: Operating system memory usage
  • Reserved Memory: Memory reserved but not yet used

Memory Limits

Default memory allocations:

  • Initial Heap: Typically 256MB or 512MB
  • Maximum Heap: Typically 1GB or 2GB
  • Metaspace: Grows as needed (Java 8+)
  • Native Memory: Varies based on system resources

Step-by-Step Configuration

Step 1: Locate Supervisor Configuration

  1. Identify Supervisor Installation: Locate Niagara Web Supervisor installation directory
  2. Configuration Files: Find supervisor configuration files:
    • supervisor.conf or supervisor.ini
    • wrapper.conf (if using Java Service Wrapper)
    • niagara.env or environment configuration files

Common locations:

  • C:\Niagara\ (Windows)
  • /opt/niagara/ (Linux)
  • Installation-specific directories

Step 2: Access Configuration Files

  1. Stop Supervisor: Stop the Niagara Web Supervisor service before editing
  2. Backup Configuration: Create backup of configuration files
  3. Open Configuration: Open configuration file in text editor with administrator privileges

Step 3: Configure Initial Heap Size

Set the initial Java heap size:

For wrapper.conf (Java Service Wrapper):

wrapper.java.initmemory=512

For supervisor.conf:

java.initmemory=512

For command-line or environment:

-Xms512m

Where 512 is the initial heap size in megabytes.

Step 4: Configure Maximum Heap Size

Set the maximum Java heap size:

For wrapper.conf:

wrapper.java.maxmemory=2048

For supervisor.conf:

java.maxmemory=2048

For command-line:

-Xmx2048m

Where 2048 is the maximum heap size in megabytes.

Step 5: Configure Garbage Collection

Configure garbage collection settings for optimal performance:

For wrapper.conf or command-line:

wrapper.java.additional.1=-XX:+UseG1GC
wrapper.java.additional.2=-XX:MaxGCPauseMillis=200
wrapper.java.additional.3=-XX:G1HeapRegionSize=16m

Or for older Java versions:

wrapper.java.additional.1=-XX:+UseParallelGC
wrapper.java.additional.2=-XX:ParallelGCThreads=4

Step 6: Configure Metaspace (Java 8+)

For Java 8 and later, configure Metaspace:

wrapper.java.additional.4=-XX:MetaspaceSize=256m
wrapper.java.additional.5=-XX:MaxMetaspaceSize=512m

Step 7: Configure Native Memory

Set native memory limits if needed:

wrapper.java.additional.6=-XX:MaxDirectMemorySize=512m

Step 8: Save and Restart

  1. Save Configuration: Save all configuration file changes
  2. Restart Supervisor: Restart the Niagara Web Supervisor service
  3. Verify Startup: Check supervisor starts successfully
  4. Monitor Memory: Monitor memory usage after restart

Memory Configuration Examples

Small Installation (< 1000 points)

wrapper.java.initmemory=256
wrapper.java.maxmemory=1024
wrapper.java.additional.1=-XX:+UseG1GC
wrapper.java.additional.2=-XX:MaxGCPauseMillis=200

Medium Installation (1000-5000 points)

wrapper.java.initmemory=512
wrapper.java.maxmemory=2048
wrapper.java.additional.1=-XX:+UseG1GC
wrapper.java.additional.2=-XX:MaxGCPauseMillis=200
wrapper.java.additional.3=-XX:G1HeapRegionSize=16m

Large Installation (> 5000 points)

wrapper.java.initmemory=1024
wrapper.java.maxmemory=4096
wrapper.java.additional.1=-XX:+UseG1GC
wrapper.java.additional.2=-XX:MaxGCPauseMillis=200
wrapper.java.additional.3=-XX:G1HeapRegionSize=32m
wrapper.java.additional.4=-XX:MetaspaceSize=512m
wrapper.java.additional.5=-XX:MaxMetaspaceSize=1024m

Monitoring Memory Usage

Using Workbench

  1. Connect to Supervisor: Connect Workbench to Supervisor
  2. System Monitor: Navigate to System Monitor or Performance Monitor
  3. Memory Metrics: View memory usage metrics:
    • Heap memory used/available
    • Non-heap memory usage
    • Garbage collection statistics
    • Memory pool details

Using Platform Services

  1. Platform Services: Access Platform Services in Workbench
  2. JVM Monitor: Use JVM monitoring tools
  3. Memory Statistics: Review memory statistics and trends

Using Operating System Tools

Windows:

tasklist /FI "IMAGENAME eq java.exe" /FO TABLE

Or use Task Manager to monitor Java process memory.

Linux:

ps aux | grep java
top -p <java_pid>

Or use jstat for detailed JVM statistics:

jstat -gc <pid> 1000

Troubleshooting

Out of Memory Errors

If experiencing out-of-memory errors:

  1. Increase Maximum Heap: Increase -Xmx value
  2. Check System Memory: Ensure system has sufficient RAM
  3. Review Memory Usage: Identify memory-intensive operations
  4. Optimise Code: Review and optimise custom code
  5. Garbage Collection: Tune garbage collection settings

High Memory Usage

If memory usage is consistently high:

  1. Monitor Trends: Track memory usage over time
  2. Identify Leaks: Look for memory leaks in applications
  3. Review Configuration: Check for unnecessary services
  4. Optimise Applications: Optimise custom applications
  5. Increase Allocation: Consider increasing maximum heap if needed

Garbage Collection Issues

If experiencing GC problems:

  1. GC Logging: Enable GC logging to analyse patterns
  2. GC Tuning: Adjust GC algorithm and parameters
  3. Heap Size: Ensure heap size is appropriate
  4. GC Frequency: Monitor GC frequency and duration
  5. Professional Tuning: Consider professional JVM tuning

Performance Degradation

If performance degrades:

  1. Memory Pressure: Check for memory pressure
  2. GC Overhead: Monitor garbage collection overhead
  3. Heap Fragmentation: Check for heap fragmentation
  4. Native Memory: Monitor native memory usage
  5. System Resources: Check overall system resources

Best Practices

Memory Sizing

  • Start Conservative: Begin with conservative memory settings
  • Monitor and Adjust: Monitor usage and adjust as needed
  • Leave Headroom: Don't allocate all available memory
  • System Resources: Reserve memory for operating system

Garbage Collection

  • Choose Appropriate GC: Select GC algorithm for your workload
  • Monitor GC Performance: Regularly monitor GC statistics
  • Tune Gradually: Make incremental GC tuning changes
  • Test Changes: Test GC changes in development first

Monitoring

  • Regular Monitoring: Monitor memory usage regularly
  • Set Alerts: Configure alerts for high memory usage
  • Trend Analysis: Analyse memory usage trends
  • Documentation: Document memory configuration and changes

Maintenance

  • Regular Reviews: Periodically review memory configuration
  • Update Settings: Update settings as system grows
  • Optimise Applications: Optimise applications to reduce memory usage
  • Keep Current: Stay current with Niagara and Java updates

Advanced Configuration

Custom JVM Arguments

Add custom JVM arguments for specific needs:

wrapper.java.additional.7=-XX:+HeapDumpOnOutOfMemoryError
wrapper.java.additional.8=-XX:HeapDumpPath=/var/log/niagara/
wrapper.java.additional.9=-XX:+PrintGCDetails
wrapper.java.additional.10=-Xlog:gc*:file=/var/log/niagara/gc.log

Memory Profiling

Enable memory profiling for analysis:

  1. Enable Profiling: Configure JVM for profiling
  2. Use Profiling Tools: Use tools like VisualVM, JProfiler
  3. Analyse Results: Analyse profiling results
  4. Optimise Based on Results: Make optimisations based on analysis

Additional Resources

  • Niagara 4 System Administration Guide
  • Java Virtual Machine Tuning Guide
  • Garbage Collection Tuning Documentation
  • Memory Management Best Practices