[rabbitmq-discuss] Problem with RabbitMQ Java Client (Memory leak)
Steve Powell
steve at rabbitmq.com
Wed Feb 1 10:42:23 GMT 2012
Yogesh,
Thank you for this problem report. First point: each connection defines a
(hidden) channel zero, so that explains why there are 20001 of some objects and
20000 of others.
As to why these are not garbage collected, we must be holding a reference
somewhere (probably in the Connection).
We will investigate. I have raised a bug (24723).
Steve Powell (a happy bunny)
----------some more definitions from the SPD----------
vermin (v.) Treating the dachshund for roundworm.
chinchilla (n.) Cooling device for the lower jaw.
socialcast (n.) Someone to whom everyone is speaking but nobody likes.
On 31 Jan 2012, at 17:49, Yogesh Ketkar wrote:
> I am using rabbitmq-java-client-bin-2.7.1/rabbitmq-client.jar with
> RabbitMQ 2.7.1 Server.
>
> Just run this code
>
> public static void main(String[] argv) throws IOException {
> ConnectionFactory f = new ConnectionFactory();
> Connection c = f.newConnection();
> for(int i = 0; i < 20000; ++i) {
> Channel ch = c.createChannel();
> ch.close();
> }
> System.gc();
> while(true) {}
> }
>
> While program is running, observe the memory usage, it keeps on
> increasing
> Get process id and do following
> jmap -dump:format=b,file=yo.bin <pid>
> jhat jhat -J-mx768m -stack false yo.bin
> Once jhat brings up http server, go here
> http://localhost:7000/showInstanceCounts/
>
> 20001 instances of class com.rabbitmq.client.impl.AMQCommand
> 20001 instances of class com.rabbitmq.client.impl.CommandAssembler
> 20000 instances of class com.rabbitmq.client.ShutdownSignalException
> 20000 instances of class com.rabbitmq.client.impl.AMQImpl$Channel
> $Close
> 20000 instances of class com.rabbitmq.client.impl.ChannelN
> 20000 instances of class com.rabbitmq.client.impl.ConsumerDispatcher
>
> In-spite of closing all the channels, not only channels but associated
> objects (ShutdownSignalException, ChannelClose) continue to consume
> memory.
> For sure, knowing this now, I will use channelCreate call sparingly.
>
> Is there a way to remedy this situation?
> What is also worrying is instances of AMQCommand, so would this be the
> case for each and every call of client library?
>
> regards, Yogesh
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
More information about the rabbitmq-discuss
mailing list