You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Corda 3节点Java堆内存不足:如何调整节点可用内存?

How to Fix Corda 3 Node OutOfMemoryError by Increasing Heap Memory

Ah, the classic java.lang.OutOfMemoryError: Java heap space when running a Corda 3 node—totally get it, especially if you're dealing with large state datasets or high transaction throughput. Let's walk through all the common ways to bump up your node's available memory, depending on how you're launching it.

1. Modify the Default Startup Scripts

If you're using Corda's out-of-the-box startup scripts (node.sh for Linux/macOS or node.bat for Windows), this is the most straightforward fix:

  • For Linux/macOS:
    Open node.sh in a text editor, look for the line setting JAVA_OPTS. You'll want to adjust the -Xms (initial heap size) and -Xmx (maximum heap size) flags. For example, to set an initial heap of 2GB and a max of 4GB, update the line to:

    JAVA_OPTS="-Xms2g -Xmx4g -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError"
    

    The -XX:+UseG1GC flag enables the G1 garbage collector, which is well-suited for Corda's workloads. -XX:+HeapDumpOnOutOfMemoryError is a handy addition—it captures a heap dump when the error occurs, making it easier to debug future issues.

  • For Windows:
    Open node.bat, find the set JAVA_OPTS line, and tweak the heap values similarly:

    set JAVA_OPTS=-Xms2g -Xmx4g -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError
    

2. Adjust Heap Size in IDE Run Configurations (Development)

If you're running your node directly from an IDE like IntelliJ IDEA for development work:

  • Head to Run > Edit Configurations
  • Locate your node's run configuration (usually named something like Node)
  • In the VM options field, add or update the heap parameters:
    -Xms2g -Xmx4g
    
  • Save the config and restart your node—you should have more memory allocated now.

3. Pass Heap Parameters Directly to the Java Command

If you're launching the node via a raw java command (e.g., running the Corda JAR directly), just append the heap flags to your command:

java -Xms2g -Xmx4g -jar corda.jar

Replace corda.jar with the actual path to your Corda node JAR file.

Quick Tips for Choosing Values

  • Use g for gigabytes or m for megabytes (e.g., -Xmx1024m equals 1GB).
  • Don't set -Xmx higher than 70-80% of your system's total RAM—leaving some memory for the OS and other processes prevents slowdowns from swapping.
  • For production nodes, you might want to dive deeper into garbage collector tuning, but adjusting -Xms and -Xmx is the first and most impactful step to fix this OOM error.

内容的提问来源于stack exchange,提问作者Joel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:08:58