Java 有OutOfMemoryError的ApacheIgnite网格计算的良好配置是什么?

Java 有OutOfMemoryError的ApacheIgnite网格计算的良好配置是什么?,java,cluster-computing,ignite,Java,Cluster Computing,Ignite,我想使用ApacheIgnite的网格计算功能,但当我在两个节点上运行程序时,Java堆空间(OutOfMemoryError)有问题。为了说明这个问题,我提出了一个简单的程序来计算字符串中的字数: try (Ignite ignite = Ignition.start("C:/Apache-Ignite/config/test-config.xml")) { IgniteCompute compute = ignite.compute(); String[] elements

我想使用ApacheIgnite的网格计算功能,但当我在两个节点上运行程序时,Java堆空间(OutOfMemoryError)有问题。为了说明这个问题,我提出了一个简单的程序来计算字符串中的字数:

try (Ignite ignite = Ignition.start("C:/Apache-Ignite/config/test-config.xml")) {
    IgniteCompute compute = ignite.compute();
    String[] elements = "Count characters using callable".repeat(10000).split(" ");
    Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
    Arrays.stream(elements).forEach(word -> calls.add((IgniteCallable<Integer>) word::length));

    IgniteReducer<Integer, Integer> reducer = new IgniteReducer<>() {
        private Integer sum = 0;
        @Override
        public boolean collect(Integer integer) {
            sum += integer;
            return true;
        }
        @Override
        public Integer reduce() {
            return sum;
        }
    };

    IgniteFuture<Integer> result = compute.callAsync(calls, reducer);
    System.out.println("Result : " + result.get());
}
try(Ignite-Ignite=Ignition.start(“C:/Apache-Ignite/config/test-config.xml”)){
IgniteCompute=ignite.compute();
String[]elements=“使用callable计数字符”。重复(10000)。拆分(“”);
集合调用=新建ArrayList();
Arrays.stream(elements).forEach(word->calls.add((可调用)word::length));
IgniteReducer=新的IgniteReducer(){
私有整数和=0;
@凌驾
公共布尔集合(整数){
总和+=整数;
返回true;
}
@凌驾
公共整数reduce(){
回报金额;
}
};
IgniteFuture结果=compute.callAsync(调用,减速机);
System.out.println(“结果:+Result.get());
}
以及test-config.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="dataStorageConfiguration">
    <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
        <!-- Redefining the default region's settings -->
        <property name="defaultDataRegionConfiguration">
            <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                <property name="name" value="Default_Region"/>
                <!-- Initial size. -->
                <property name="initialSize" value="#{2L * 1024 * 1024 * 1024}"/>
                <!-- Maximum size. -->
                <property name="maxSize" value="#{2L * 1024 * 1024 * 1024}"/>
            </bean>
        </property>
    </bean>
</property>
</bean>
</beans>



当我在程序执行期间观察堆时,我们可以清楚地看到堆达到了他的极限。也许垃圾收集器锁上了,但我不知道


此外,如果我在单个本地节点上运行我的程序(从
Ignition.start(“…”)
)开始,我没有任何问题。

我刚刚重新尝试了您的情况,似乎
callAsync()
性能随着
调用.size()
超过5000次而变得越来越差。 在您的情况下,它是~40000,因此您不会看到此调用的完成,即使它不会导致OOM

请确保将您的计算机分成约1000个呼叫的批次。实际上,有人建议,计算作业是非常重要的,在您的情况下,无论如何,您将花费99%的资源来整理作业及其参数


尽管如此,我将对此行为提交一份记录。

您能在堆转储上运行堆分析,与我们共享泄漏嫌疑犯/支配者树吗?我的堆中充满了
字节[]
(98,8%的堆)的活动字节,它们从何处引用?我无法使用我的分析器查看--“尝试使用Eclipse MAT”。提交记录: