android rabbitmq客户端连接内存不足

时间:2016-07-22 09:24:31

标签: android rabbitmq out-of-memory

我有以下简单的代码尝试使用RabbitMQ Java客户端连接到CloudAMQP来获取消息。 logcat显示正在建立的某个连接,但随后它会抛出OutOfMemoryError(在AVD和物理设备上)。 在调用factory.newConnection()时抛出OutOfMemory:

ConnectionFactory factory = new ConnectionFactory();
try {
        Log.d(MainActivity.LOG, "MQuri: " + uri);
        factory.setUri(uri);
} catch (Exception e1) {
        Log.d("", "Connection broken: " + e1.getClass().getName() + ": " + e1.getMessage() );
        e1.printStackTrace();
}

factory.setAutomaticRecoveryEnabled(false);
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.basicQos(1);

String MQQueue = MainActivity.getMQQueue(appcontext);
channel.queueDeclare(MQQueue, false, false, false, null);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(MQQueue, false, consumer);

任何可能是原因的提示?

连接建立如下:

07-22 05:22:24.533: I/dalvikvm-heap(833): Forcing collection of SoftReferences for 1345270078-byte allocation
07-22 05:22:24.603: D/dalvikvm(833): GC_BEFORE_OOM freed 70K, 18% free 2588K/3140K, paused 59ms, total 60ms
07-22 05:22:24.603: E/dalvikvm-heap(833): Out of memory on a 1345270078-byte allocation.
07-22 05:22:24.603: I/dalvikvm(833): "AMQP Connection 146.148.11.249:443" prio=5 tid=12 RUNNABLE
07-22 05:22:24.603: I/dalvikvm(833):   | group="main" sCount=0 dsCount=0 obj=0x416f23a0 self=0x2a1be3e8
07-22 05:22:24.634: I/dalvikvm(833):   | sysTid=853 nice=0 sched=0/0 cgrp=apps/bg_non_interactive handle=706471992
07-22 05:22:24.634: I/dalvikvm(833):   | state=R schedstat=( 99662493 40632307 23 ) utm=8 stm=1 core=0
07-22 05:22:24.634: I/dalvikvm(833):   at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:~116)
07-22 05:22:24.634: I/dalvikvm(833):   at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139)
07-22 05:22:24.634: I/dalvikvm(833):   at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:542)
07-22 05:22:24.634: I/dalvikvm(833):   at java.lang.Thread.run(Thread.java:841)
07-22 05:22:24.673: D/(833): Connection broken: java.io.IOException: null
07-22 05:22:24.683: W/System.err(833): java.io.IOException

0 个答案:

没有答案