This page was last modified 08:17, 25 March 2008.
KIJ000852 - Repeating socket connections with default access point result in Out of Memory exception in the Nokia N95
From Forum Nokia Wiki
| ID | KIJ000852 | Creation date | March 25, 2008 |
| Platform | S60 3rd Edition, Feature Pack 1 | Devices | Nokia N95 |
| Category | Java ME | Subcategory | Networking, MIDP 2.0 |
Description
When making several socket connections with a default access point with the Nokia N95, an Out of Memory exception will be thrown. If the socket MIDlet will remain open after the exception, any attempt to connect to the network (for example, by using a Web browser) results in a new Out of Memory exception. However, when using the device's other applications, no exceptions will be thrown, suggesting that the problem is originating from the number of socket connections. After closing the socket MIDlet, connecting to the network with other applications succeeds and no exception will be thrown.
How to reproduce
The problem can be reproduced with a test MIDlet which makes recursive socket connection calls. The basic code for a test MIDlet can be as follows:
boolean recursive=false
..
while(!recursive) {
SocketConnection socon = null;
InputStream inputs = null;
OutputStream outputs = null;
..
socon = (SocketConnection) Connector.open("socket://address.com:portNumber");
outputs = socon.openOutputStream();
inputs = socon.openDataInputStream();
For example, make a GET request for fetching a Web page and write it to the output stream:
StringBuffer req = new StringBuffer(intSize);
req.append("GET ");
.. // Append HTTP, Content type and other data here
outputs.write(req.toString().getBytes());
outputs.flush();
..
int c = inputs.read(); // Read the feedback from the Web to input stream
..
// Handle the input here
..
inputs.close();
outputs.close();
socon.close();
} //closing the while(!recursive) loop
Test procedure:
1. Install the test MIDlet.
2.Go to Menu > Settings > Application Manager > <Test MIDlet> > Open > Access Point and select a properly configured Access Point.
3. Start the test MIDlet.
4. Allow the MIDlet to access the Internet. After about 150-200 connections an OutOfMemoryError will be thrown and no new socket connections can be made.
5. Put the test MIDlet in the background. Start the native Web browser and try going to an URL.
6. Close the test MIDlet and try again to go to an URL using the native Web browser.
Solution
No solution for S60 3rd Edition, FP1. This is expected to be fixed in future software releases.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HTTPS in MIDP | MBarbic | Mobile Java General | 1 | 2002-11-19 05:45 |
| GPRS avaibility check in J2ME | waqas nisar | Mobile Java General | 2 | 2007-02-17 02:54 |
| Locked-up closing an InputStream of a Socket Connection | tony.sung | Mobile Java Networking & Messaging & Security | 2 | 2006-10-27 21:47 |
| Multiple requests with HTTPConnection | tinkywinky | Python | 3 | 2007-07-11 17:51 |
| Nokia 5300: problems with pushregistry and socket | rabbini76 | Mobile Java Networking & Messaging & Security | 5 | 2007-01-25 12:56 |

