You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Safa <sa...@gmail.com> on 2009/03/03 16:34:11 UTC
InetAddress possibly using up memory
Hi Everyone,
I am running a multiplayer game server based on MINA, where 8k users can be
online at certain times of a day. For the latest update I have been doing to
my server, I needed to determine if multiple accounts log in from the same
IP address. For this, I used IoSession.getRemoteAddress() and downcast to
InetAddress, then store the result of getHostName() in a string.
When I ran the server, it quickly got out of memory. When I searched the web
for the issue, I came to a guess that InetAdress' reverse lookup cache may
be filling memory and I saw that people are discouraging the use of
InetAddress.
The question is, is there an efficient way to compare users' IP addresses?
What can you say about InetAddress.hashCode(), InetAddress.getAddress() and
InetAddress.toString()?
Thanks,
Safa Sofuoğlu
Re: InetAddress possibly using up memory
Posted by Squee <sq...@gmail.com>.
Don't use getHostName() is all you care about is the IP address.
getHostName() will attempt a reverse name lookup which not only is
usually unnecessary, but can take up a lot of extra time and
resources. Stick with getHostAddress() and getAddress(). getAddress()
is your best bet as an integer is a lot less memory than the string.
Also, if you DO need to do reverse name lookups (or normal DNS
lookups), I highly recommend avoiding Java's builtin resolver, and use
something like DNSJava, which tends to be much faster and not subject
to Java and OS settings causing problems.
2009/3/3 Emmanuel Lecharny <el...@apache.org>:
> Safa wrote:
>>
>> Hi Everyone,
>>
>> I am running a multiplayer game server based on MINA, where 8k users can
>> be
>> online at certain times of a day. For the latest update I have been doing
>> to
>> my server, I needed to determine if multiple accounts log in from the same
>> IP address. For this, I used IoSession.getRemoteAddress() and downcast to
>> InetAddress, then store the result of getHostName() in a string.
>>
>
> Why don't you just store the address in a 'int' ? If it's a Inet4 address,
> it should be just what you need to keep an address in memory, and you
> certainly can hold hundred of thousands of those guys in memory...
>
> The only problem is when you have more than one port used for a IP
> address...
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>
Re: InetAddress possibly using up memory
Posted by Emmanuel Lecharny <el...@apache.org>.
Safa wrote:
> Hi Everyone,
>
> I am running a multiplayer game server based on MINA, where 8k users can be
> online at certain times of a day. For the latest update I have been doing to
> my server, I needed to determine if multiple accounts log in from the same
> IP address. For this, I used IoSession.getRemoteAddress() and downcast to
> InetAddress, then store the result of getHostName() in a string.
>
Why don't you just store the address in a 'int' ? If it's a Inet4
address, it should be just what you need to keep an address in memory,
and you certainly can hold hundred of thousands of those guys in memory...
The only problem is when you have more than one port used for a IP
address...
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org