apache-flexmavenflexmojos

Maven flexmojos-maven-plugin fails with OutOfMemoryError even with -Xmx1024m -XX:MaxPermSize=512m


I'll be answering my own question to provide bread crumbs for the next person who hits this:

Problem

x86Linux Maven build fails during flexmojos-maven-plugin with

load-config+=...flex-config.xml -static-link-runtime-shared-libraries...
-metadata.language+=en_US 
[INFO] Loading configuration file .../flex-config.xml

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 37064 bytes for Chunk::new
[ERROR] OutOfMemoryError -> [Help 1]

Solution

  • Solution

    Increase system swap. The flexmojos call out fo the flex compiler (a native executable that requires memory outside of that which is allocated for the JVM). If you run low on memory and can't swap out maven's jvm them the flex compiler fails.

    I added additional swap and was able to complete the build successfully.

    from enter link description here

    # create swap file
    dd if=/dev/zero of=/opt/swapfile.1 bs=1M count=2048
    # Set Permissions
    chmod 600 /opt/swapfile.1
    # Define as swap
    mkswap /opt/swapfile.1
    # Add to active swap
    swapon /opt/swapfile.1
    # Verify
    free -m