【发布时间】:2018-07-18 23:37:57
【问题描述】:
我正在尝试在 AMQ (5.15.2) 上发送 BytesMessage,但即使内存明显可用,我也会在堆空间异常中运行。这里是
byte[] contcentBuilder = new Byte[1000*1000*1];
Array.fill(contentBuilder, (byte) 1);
BytesMessage message = session.createBytesMessage();
for(int i=0;i<150;i++){
message.writeBytes(contentBuilder);
}
contentBuilder=null;
producer.send(message); //here it gets the heap space memory error
Runtime.getRunTime().freeMemory(); //this is in debug
在该错误中,可用内存超过 15Gb(我为此 VM 分配了 16Gb)。
欢迎任何想法,谢谢。
编辑:我基本上很笨,问题出在 AMQ 方面,增加它在 bin/win64/wrapper.conf 中的内存就可以了。感谢所有回答的人。
新来的我不知道如何关闭这个答案!
【问题讨论】:
-
你确定这还能编译吗?
byte[]与Byte[]不同。 -
此外,我做了一些帐户,该数组分配的内存约为 0.0009 GB "matisse.net/bitcalc/…" 这让我认为问题不在于分配给 VM 的内存
-
@GianfrancescoAurecchia,实际上是 1.5 亿字节。如果我了解
BytesMessage的作用。 -
所以我会说在执行命令时使用-Xmx,让我知道它是怎么回事
-
对不起,我没有重视循环,在所有情况下只占用 0.1396 GB
标签: java jms heap-memory activemq amq