Cannot allocate memory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Abhinay
    New Member
    • Jul 2006
    • 44

    Cannot allocate memory

    hi,

    I have created a echo server which accepts request from client , for each client request processing my server creates new thread but after creating 305 thread it says "Cannot allocate memory" Errocode = 12.

    I have close socket of both sides as well as use PTHREAD_CREATE_ DETACHED flage while thread creation.

    I am working on CentOS (linux) and using pthread_create( ) function for thread creation.

    your help will be appriciated.

    Thanks
    Abhinay
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It would appear that your system has run out of memory. If you think this is unlikely then the first thing to work out is how much memory you have actually allocated and how much memory each thread allocates.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Do you ever free any memory?

      Comment

      • Abhinay
        New Member
        • Jul 2006
        • 44

        #4
        Originally posted by donbock
        Do you ever free any memory?

        Thanks for your reply,
        My server thread only receive transaction ( using socket ) information and insert into database after that I close socket ( from both side ) and terminate the corresponding thread. I have not allocated any memory using "new" operator in my code.

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          Originally posted by Abhinay
          I have not allocated any memory using "new" operator in my code.
          You must be allocating per-thread memory somehow, or else you wouldn't be getting an out-of-memory error after the 305th thread.

          Comment

          • Abhinay
            New Member
            • Jul 2006
            • 44

            #6
            Thank all of you for helping me,
            I have solve issue using connection pool.

            Thank you
            Abhinay

            Comment

            Working...