Our application have a backend thread that will send many messages(say >4000) to JBoss MQ. In our QA server(Windows2000 P4 2.6G, 1 CPU, 1Gmemory), we don't have this problem. But with customer's production server(windows2003 P4 3.xG, 2 CPU, 2G memory), OutOfMemoryError occured.
We have follow up the guideline in wiki page: http://wiki.jboss.org/wiki/Wiki.jsp?page=OutOfMemoryExceptionWhenCannotCreateThread
Add -XX:ThreadStackSize=128 JVM parameter to JBoss run.bat
It didn't work. We suspect it may be the application enqueuing too many messages(each will need a pair of readTask/WrtieTask threads) which cause to reach OS's maximum thread count limitation. So we add a loop wait to sleep 1 mins for every 200 messages. It works for about 2 days. Whne we restarted the JBoss today, the error occured again.
Can anyone help? Do we go the wrong way?
Note: If we run JBoss as windows service, the error occured more frequently. It seems the thread count limitation is much less.
Our application have 2 message consumers at the same time.
For today's error, it only send out less than 200 messages. We changed to loop wait to sleep 1 mins for 100 messages. From our log files, the error occured after only one sleep.