1

I'm now using Android as my Netty client. And Windows as my Netty Server. Recently, I find a strange behavior on Netty. When I open the server-side app, the memory is only 30MB. But after several hours, it rises up to 300M. Its 10x compared to the original memory usage. The longer I open the server, the more memory it will increase.

I don't know why this is happening. Is it normal?

By the way, since Netty doesn't support built-in server push feature. So I use a static method to store all of the Channel in the map:

public static final Map<Integer, Channel> mapConcurrentIdChannel = new ConcurrentHashMap<Integer, Channel>();

I map the channel ID to Channel. For example: Whenever client A wants to push message to client B, the server will find the channel id and thus get the Channel instance, then use Channel.write(object) method. Is this a correct method to implement Push Message feature in Netty? (If not, could you please suggest a good method to implement Push feature? Since there's no official docs mention that) Also, I'm afraid this implementation causes "Memory Leak Problem" which I explain earlier.

About using ChannelGroup:
My scenario is if there are 5 people, A, B, C, D, E. Sometimes, A wants to send message to C, and sometimes B wants to send message to E. I can't predict when somebody will send message to somebody and who they will send to. So I can't add all the 5 people(connection) to the ChannelGroup, which writing to that group would broadcast the message to everyone.

I've searched on Google for a long time and nothing help on my problem I'm now facing. Wish to hear some recommendations from Netty experienced developers, you!!

Thanks!!

4

1 回答 1

1

我认为您想为此使用 ChannelGroup[1] ,这基本上也只是使用 ConcurrentMap put 确保 Channel 在关闭时被删除等。

[1] http://netty.io/3.6/api/org/jboss/netty/channel/group/DefaultChannelGroup.html

于 2013-05-28T04:57:20.300 回答