470,587 Members | 1,807 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,587 developers. It's quick & easy.

Cannot allocate memory


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.

Nov 3 '08 #1
5 5372
9,065 Expert Mod 8TB
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.
Nov 3 '08 #2
2,425 Expert 2GB
Do you ever free any memory?
Nov 3 '08 #3
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.
Nov 4 '08 #4
2,425 Expert 2GB
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.
Nov 5 '08 #5
Thank all of you for helping me,
I have solve issue using connection pool.

Thank you
Nov 6 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

37 posts views Thread by Curt | last post: by
4 posts views Thread by Franklin Lee | last post: by
5 posts views Thread by lixiaoyao | last post: by
3 posts views Thread by jcgeorge | last post: by
12 posts views Thread by gc | last post: by
1 post views Thread by rveloso | last post: by
2 posts views Thread by lovecreatesbea... | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.