increasing memory usage

"Trustin Lee (이희승)" trustin at gmail.com
Wed Jan 27 09:12:26 EST 2010


According to the heap dump, a lot of buffers are stuck in the event
queue of a NioClientSocketChannel.  The channel's interestOps is 5
(OP_READ + OP_WRITE), which means the channel's socket send buffer is
full.  Because your write request cannot be completed due to the full
socket buffer, it will be kept in the event queue and eventually cause OOME.

Why is the socket buffer full?  It's perhaps because the server is not
reading the data you are sending at all.  You have to disconnect or stop
sending data in such a case.

Generally, such a problematic server does not send a response message
for the message you've sent.  You could maintain an integer variable
that counts the number of unanswered requests and disconnect if the
counter becomes greater than a certain threshold.  In a normal
connection, the counter will be increased and then decreased because the
responses will be received fairly quickly.

Just in case you think the server is just fine and something's wrong
with Netty, provide me the full source code of the client-server pair
that reproduces the problem.

HTH,
Trustin

Mahmood Rahmani wrote:
> sorry, i meant -Xmx16m
> 
> 
> On Jan 27, 2010, at 2:13 PM,  wrote:
> 
>> here is the heap dump for -Xmx96m:
>> http://tinyurl.com/yeggxb7
>>
>>
>>
>> On Jan 27, 2010, at 12:53 PM, Trustin Lee (이희승) wrote:
>>
>>> Oh, that's too bad.  Then could you post the heap dump file?  You can
>>> configure your VM to generate heap dump on OutOfMemoryError:
>>>
>>>    -XX:+HeapDumpOnOutOfMemoryError
>>>
>>> For more information on generating heap dump, read this article:
>>>
>>>    http://blogs.sun.com/alanb/entry/heap_dumps_are_back_with
>>>
>>> I would still recommend to decrease the max heap size so that you can
>>> get OOME sooner so that heap dump is generated sooner.
>>>
>>> cyrus77 wrote:
>>>> Hi, 
>>>>
>>>> Thanks for your reply,
>>>>
>>>> Unfortunately yes, I get OutOfMemoryError.
>>>> How can we investigate it? any idea? 
>>>>
>>>> Thanks,
>>>> Cyrus
>>>>
>>>>
>>>> On Jan 27, 2010, at 11:31 AM, Trustin Lee [via Netty Forums and Mailing Lists] wrote:
>>>>
>>>>> If you do not get an OutOfMemoryError, it is safe to decrease the 
>>>>> maximum heap size of the VM with -Xmx option.  I'd cut down to 96MB 
>>>>> (i.e. -Xmx96m). 
>>>>>
>>>>> If you get an OutOfMemoryError eventually, that's more like a memory 
>>>>> leak that needs more investigation. 
>>>>>
>>>>> cyrus77 wrote:
>>>>>
>>>>>> Hi, 
>>>>>>
>>>>>> I am using Netty to develop a simple TCP client and connect to a server to 
>>>>>> receive data 24x7. The data being transferred is not much, its around 100KB 
>>>>>> to 200KB per minute. 
>>>>>>
>>>>>> The problem is that the client starts allocating memory gradually and after 
>>>>>> some hours or a day (depending on how much data is being sent by the server 
>>>>>> to this client) the allocated heap memory reaches up to 500 MB! 
>>>>>>
>>>>>> The thing is that even if I do nothing with the message (do nothing in 
>>>>>> messageReceived method) the problem still exist! 
>>>>>>
>>>>>> I attached the code if you would like to take a look. 
>>>>>> http://n2.nabble.com/file/n4466226/code.java code.java 
>>>>>>
>>>>>> Do you have any idea what is wrong with it? 
>>>>>>
>>>>>> Thanks, 
>>>>>> Cyrus 
>>>>>>
>>>>> -- 
>>>>> what we call human nature in actuality is human habit 
>>>>> http://gleamynode.net/
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________ 
>>>>> netty-users mailing list 
>>>>> [hidden email] 
>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>
>>>>> signature.asc (268 bytes) Download Attachment
>>>>> — Trustin Lee, http://gleamynode.net/
>>>>>
>>>>>
>>>>> View message @ http://n2.nabble.com/increasing-memory-usage-tp4466226p4466366.html 
>>>>> To unsubscribe from increasing memory usage, click here.
>>>>>
>>>>
>>> -- 
>>> what we call human nature in actuality is human habit
>>> http://gleamynode.net/
>>>
>>>
>>> <signature.asc>_______________________________________________
>>> netty-users mailing list
>>> netty-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/netty-users
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100127/b2a1aaa3/attachment.bin 


More information about the netty-users mailing list