Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError in Socket Programming in Java

 
Kaushik Mehta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic