By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

Cannot allocate memory

P: 44

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
Share this Question
Share on Google+
5 Replies

Expert Mod 5K+
P: 8,916
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

Expert 100+
P: 2,400
Do you ever free any memory?
Nov 3 '08 #3

P: 44
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

Expert 100+
P: 2,400
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

P: 44
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.