Results 1 to 4 of 4
  1. #1
    mvillara is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default Problem with Java Heap Space using Socket

    Hi,

    I have a Server in Java using Socket and ServerSocket and a client. Well, the communication is perfect. The server must send about 35 - 300 packets per second. Well, when the process is working about 4 or 5 hours, the server goes down with an error: OutOfMemoryError: Java heap Space. How can i solve this problem? I know that its a virtual memory issue and i know how to increase it but the problem will persist some hours later if i increase it.

    Does anyone know any technic?

    Thanks in advance.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    808
    Rep Power
    6

    Default

    Using JProfiler,you can check which part of code is taking more memory and we can do some correction related to our design.If not,let me think some other option and tell you.
    Ramya:cool:

  3. #3
    mvillara is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default

    Hi RamyaSivakanth,

    Thanks for your reply. I will check JProfile to learn how to use it.
    By now, i have running the Server with the client connected and sending packets continuosly watching with Runtime.freeMemory() the virtual memory available and i can see that the memoria start decreasing from 70Mb to 60Mb and suddently it recover back, so it seems that works fine but not.... we have to wait for 4 hours to see how the memory down to almost 0 bytes free.

    The sever alway has the same work.

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    The garbage collector will wait until a certain amount of the heap is in use and then reclaim old objects to get the heap space back, so having the heap space drop and then restore is normal.

    On the other hand, 60 - 70 MB is not much memory, especially for a server. I provide 512 MB just to run Netbeans or Eclipse. While dwindling memory indicates a memory leak, if you don't provide a large enough heap, you may simply not have enough heap for your server to run, especially when it is handling so many transactions.

    What are your heap settings?

Similar Threads

  1. Java heap space OutofMemoryError
    By everlast88az in forum Advanced Java
    Replies: 3
    Last Post: 05-18-2009, 08:12 AM
  2. [SOLVED] Java heap space OutOfMemoryError
    By loki in forum New To Java
    Replies: 14
    Last Post: 04-25-2009, 04:11 PM
  3. Java Heap Space
    By sandeeprao.techno in forum Advanced Java
    Replies: 19
    Last Post: 10-30-2008, 11:27 AM
  4. Java heap space error
    By gezzel in forum New To Java
    Replies: 19
    Last Post: 09-25-2008, 12:07 AM
  5. Java heap space?
    By javanewbie in forum New To Java
    Replies: 1
    Last Post: 06-24-2008, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •