This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hello,
I am looking at the gnu::java::net::PlainDatagramSocketImpl::receive code because it allocates memory on the heap when it should not need to (the Sun JDK does not seem to allocate on the heap with the same program).
The reason for the allocation seems to be that the IP address is stored as an array and since the IP address may be 4 or 16 byte long (IPv6) the code just reallocates the array to store the IP address every time a new message is received.
I would like to avoid that and do the following :
1) check that an IP address with an byte array of the right size is available
2) if not execute the current code (i.e. allocate an new InetAddress instance and fill it with the data)
3) if there is an InetAddress instance that can be reused, update the byte array.
It seems that I would need to modify InetAddress.java (add a protected/private setAddress method) and PlainDatagramSocketImpl (use the new method in InetAddress to update the address instead of allocating a new one).
Of course, this might cause unwanted side-effects for programs that kept a reference on the address found in the datagram instead of making a copy.
So, I would like guidance from the GCJ folks : 1) does the change seem reasonable ? 2) could I submit a patch and to whom ?
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |