This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Sockets and Internet Protocols and the fly likes java.lang.OutOfMemoryError in Socket Programming in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.lang.OutOfMemoryError in Socket Programming in Java" Watch "java.lang.OutOfMemoryError in Socket Programming in Java" New topic
Author

java.lang.OutOfMemoryError in Socket Programming in Java

Kaushik Mehta
Greenhorn

Joined: Feb 10, 2003
Posts: 4
Hi,
I ve a program which starts 2 threads. One thread opens a server socket that listens for any clients to connects to it. Once a client connects it would read whatever the client sends to it and then some processing is done and reply is sent thru the other thread. My problem is keep getting this error sometime after the program starts running. I first thought this might be due to improper creation and destroying of objects. But this error crops up even when there are no client connections(I create other objects only when a client connects. before that only 2 theads are created). So even if the Server Socket just keeps listening for client connections, after sometime this message crops up and no further clients can connect. Please help me.
Thanks in advance,
Kaushik
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,
Maybe you could show us some code. WHen there are no clients, the server should just be stuck at a call to "accept()," and this shouldn't be using any resources as all.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.OutOfMemoryError in Socket Programming in Java