You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Michele Mazzucco <mi...@gmail.com> on 2008/05/01 19:09:39 UTC

java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Hi all,

I'm facing the following error while using AMQ 5.0

ERROR efaultMessageListenerContainer - Setup of JMS message listener
invoker failed - trying to recover
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
        at org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
        at org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
        at org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
        at org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
        at java.lang.Thread.run(Thread.java:595)
Exception in thread "DefaultMessageListenerContainer-29"
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)ERROR
Service                        - Async error occurred:
java.lang.OutOfMemoryError: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
        at org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
        at java.lang.Thread.run(Thread.java:595)

        at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
        at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
        at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
        at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
        at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
        at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
        at java.lang.Thread.run(Thread.java:595)
Exception in thread "ActiveMQ Transport Server: tcp://localhost:61616"
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
        at org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
        at java.lang.Thread.run(Thread.java:595)
ERROR Service                        - Async error occurred:
java.lang.OutOfMemoryError: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
        at org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
        at java.lang.Thread.run(Thread.java:595)
INFO  BrokerService                  - ActiveMQ Message Broker
(localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is shutting
down
INFO  NetworkConnector               - Network Connector
org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@17c96a9
Stopped
INFO  TransportConnector             - Connector openwire Stopped
INFO  TransportConnector             - Connector vm://localhost Stopped
WARN  ActiveMQConnection             - Async exception with no
exception listener:
org.apache.activemq.transport.TransportDisposedIOException: Peer
(vm://localhost#1) disposed.
org.apache.activemq.transport.TransportDisposedIOException: Peer
(vm://localhost#1) disposed.
        at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:200)
        at org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
        at org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)
INFO  BrokerService                  - ActiveMQ JMS Message Broker
(localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
INFO  AdvisoryConsumer               - Failed to send remove command:
javax.jms.JMSException: Peer (vm://localhost#1) disposed.
javax.jms.JMSException: Peer (vm://localhost#1) disposed.
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
        at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1154)
        at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56)
        at org.apache.activemq.ActiveMQConnection.cleanup(ActiveMQConnection.java:1326)
        at org.apache.activemq.ActiveMQConnection.transportFailed(ActiveMQConnection.java:2027)
        at org.apache.activemq.ActiveMQConnection$4.run(ActiveMQConnection.java:1663)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.activemq.transport.TransportDisposedIOException:
Peer (vm://localhost#1) disposed.
        at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:87)
        at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
        at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:59)
        at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1152)
        ... 7 more


My broker is running on a linux box with kernel 2.6 (I've read about
some similar issues when running on a kernel 2.4).
I'm using the following options when starting AMQ:
-Xms512m -Xmx1024m -Xmn500m

I'm using the default configuration (no persistence).
I don't know whether it can help to diagnose the problem, my clients
are creating a lot of temporary queues (everything is cleaned up after
use), but their lifetime is very short (a few seconds, they are just
used to receive a response message).
A similar problem occurs on my test client too (maybe it's related to
the error on the broker), but not on the server.


Any help would be appreciated,
Michele

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Michele Mazzucco <mi...@gmail.com>.
Hi again,

here are the full stack traces.

1 - Broker
Loading message broker from: xbean:activemq.xml
INFO  BrokerService                  - Using Persistence Adapter:
AMQPersistenceAdapter(/work/michele/apache-activemq-5.0.0/data/localhost)
INFO  BrokerService                  - ActiveMQ 5.0.0 JMS Message
Broker (localhost) is starting
INFO  BrokerService                  - For help or more information
please see: http://activemq.apache.org/
INFO  AMQPersistenceAdapter          - AMQStore starting using
directory: /work/michele/apache-activemq-5.0.0/data/localhost
INFO  ManagementContext              - JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO  KahaStore                      - Kaha Store using data directory
/work/michele/apache-activemq-5.0.0/data/localhost/kr-store/state
INFO  AMQPersistenceAdapter          - Active data files: []
WARN  AMQPersistenceAdapter          - The ReferenceStore is not valid
- recovering ...
INFO  KahaStore                      - Kaha Store successfully deleted
data directory /work/michele/apache-activemq-5.0.0/data/localhost/kr-store/data
INFO  AMQPersistenceAdapter          - Journal Recovery Started from:
DataManager:(data-)
INFO  AMQPersistenceAdapter          - Recovered 0 operations from
redo log in 0.051 seconds.
INFO  AMQPersistenceAdapter          - Finished recovering the ReferenceStore
INFO  KahaStore                      - Kaha Store using data directory
/work/michele/apache-activemq-5.0.0/data/localhost/kr-store/data
INFO  TransportServerThreadSupport   - Listening for connections at:
tcp://giga06.ncl.ac.uk:61616
INFO  TransportConnector             - Connector openwire Started
INFO  NetworkConnector               - Network Connector
org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@1d8d237
Started
INFO  BrokerService                  - ActiveMQ JMS Message Broker
(localhost, ID:giga06.ncl.ac.uk-41899-1209722312855-0:0) started
INFO  TransportConnector             - Connector vm://localhost Started
ERROR efaultMessageListenerContainer - Setup of JMS message listener
invoker failed - trying to recover
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:597)
        at org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
        at org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
        at org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
        at org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
        at org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
        at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
        at java.lang.Thread.run(Thread.java:619)
ERROR Service                        - Async error occurred:
java.lang.OutOfMemoryError: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:597)
        at org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
        at org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
        at java.lang.Thread.run(Thread.java:619)
Exception in thread "DefaultMessageListenerContainer-100"
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:597)
        at org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)
        at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
        at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
        at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
        at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
        at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
        at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
        at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
        at java.lang.Thread.run(Thread.java:619)
Exception in thread "ActiveMQ Transport Server: tcp://localhost:61616"
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:597)
        at org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
        at org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
        at java.lang.Thread.run(Thread.java:619)
INFO  BrokerService                  - ActiveMQ Message Broker
(localhost, ID:giga06.ncl.ac.uk-41899-1209722312855-0:0) is shutting
down



2 - Client
ERROR 10:41:58,582 (ClientTask.java:250) - unable to create new native thread
     [java]     at
org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
     [java]     at
org.apache.activemq.broker.region.Queue.<init>(Queue.java:125)
     [java]     at
org.apache.activemq.broker.region.TempQueueRegion$1.<init>(TempQueueRegion.java:54)
     [java]     at
org.apache.activemq.broker.region.TempQueueRegion.createDestination(TempQueueRegion.java:44)
     [java]     at
org.apache.activemq.broker.jmx.ManagedTempQueueRegion.createDestination(ManagedTempQueueRegion.java:56)
     [java]     at
org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:116)
     [java]     at
org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:262)
     [java]     at
org.apache.activemq.broker.region.RegionBroker.addDestinationInfo(RegionBroker.java:300)
     [java]     at
org.apache.activemq.broker.BrokerFilter.addDestinationInfo(BrokerFilter.java:213)
     [java]     at
org.apache.activemq.advisory.AdvisoryBroker.addDestinationInfo(AdvisoryBroker.java:157)
     [java]     at
org.apache.activemq.broker.BrokerFilter.addDestinationInfo(BrokerFilter.java:213)
     [java]     at
org.apache.activemq.broker.MutableBrokerFilter.addDestinationInfo(MutableBrokerFilter.java:223)
     [java]     at
org.apache.activemq.broker.TransportConnection.processAddDestination(TransportConnection.java:456)
     [java]     at
org.apache.activemq.command.DestinationInfo.visit(DestinationInfo.java:122)
     [java]     at
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
     [java]     at
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
     [java]     at
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
     [java]     at
org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
     [java]     at
org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
     [java]     at
org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
     [java]     at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
     [java]     at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
     [java]     ... 1 more
     [java] javax.jms.JMSException: unable to create new native thread
     [java]     at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
     [java]     at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1178)
     [java]     at
org.apache.activemq.ActiveMQConnection.createTempDestination(ActiveMQConnection.java:1720)
     [java]     at
org.apache.activemq.ActiveMQSession.createTemporaryQueue(ActiveMQSession.java:1218)
     [java]     at
benchmark.db.pooled.client.ClientTask.call(ClientTask.java:204)
     [java]     at
benchmark.db.pooled.client.ClientTask.call(ClientTask.java:56)
     [java]     at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
     [java]     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
     [java]     at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
     [java]     at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
     [java]     at java.lang.Thread.run(Thread.java:619)
     [java] Caused by: java.lang.OutOfMemoryError: unable to create
new native thread
     [java]     at java.lang.Thread.start0(Native Method)
     [java]     at java.lang.Thread.start(Thread.java:597)


Michele


On Fri, May 2, 2008 at 10:26 AM, Michele Mazzucco
<mi...@gmail.com> wrote:
> Filip,
>
>  are you talking about the broker or the client? The settings below are for
> the broker.
>
>  Michele
>
>
>  On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:
>
>
> >
> > >
> > > >
> > > > > -Xms512m -Xmx1024m -Xmn500m
> > > > >
> > > >
> > >
> >
>
>

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Rob Davies <ra...@gmail.com>.
that's from trunk ?
On 16 May 2008, at 20:12, Hiram Chirino wrote:

> Looks like my memory problems are all related to the kaha HashIndex:
>
> By the time I create 3000 queues, there are about 5000 HashIndex
> object allocated.  The retained size of those HashIndex objects is
> about 187 megs.  163 megs of that are just byte[]s being held directly
> by the HashIndex and the DataByteArraOutputStream that the HashIndex
> holds onto.
>
> Rob, any chances of reducing the number of HashIndex (or the amount of
> memory each one needs) objects held in memory?
>
> Regards,
> Hiram
>
> On Fri, May 16, 2008 at 2:44 PM, Hiram Chirino  
> <hi...@hiramchirino.com> wrote:
>> I modified your case so that it's a JUnit test and so that it starts
>> an embedded broker.. I did not see the threading problem against the
>> trunk, but I did see :
>>
>> javax.jms.JMSException: Java heap space
>>       at  
>> org 
>> .apache 
>> .activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java: 
>> 49)
>>       at  
>> org 
>> .apache 
>> .activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java: 
>> 1201)
>>       at  
>> org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1648)
>>       at  
>> org 
>> .apache 
>> .activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java: 
>> 227)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .ActiveMQMessageProducerSupport 
>> .send(ActiveMQMessageProducerSupport.java:300)
>>       at org.apache.activemq.App.testSend(App.java:34)
>>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>       at  
>> sun 
>> .reflect 
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>       at  
>> sun 
>> .reflect 
>> .DelegatingMethodAccessorImpl 
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>       at java.lang.reflect.Method.invoke(Method.java:585)
>>       at junit.framework.TestCase.runTest(TestCase.java:154)
>>       at junit.framework.TestCase.runBare(TestCase.java:127)
>>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>>       at junit.framework.TestResult.run(TestResult.java:109)
>>       at junit.framework.TestCase.run(TestCase.java:118)
>>       at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>       at junit.framework.TestSuite.run(TestSuite.java:203)
>>       at  
>> org 
>> .eclipse 
>> .jdt 
>> .internal 
>> .junit 
>> .runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>>       at  
>> org 
>> .eclipse 
>> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>       at  
>> org 
>> .eclipse 
>> .jdt 
>> .internal 
>> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>>       at  
>> org 
>> .eclipse 
>> .jdt 
>> .internal 
>> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>>       at  
>> org 
>> .eclipse 
>> .jdt 
>> .internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java: 
>> 386)
>>       at  
>> org 
>> .eclipse 
>> .jdt 
>> .internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java: 
>> 196)
>> Caused by: java.lang.OutOfMemoryError: Java heap space
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .util 
>> .DataByteArrayOutputStream.<init>(DataByteArrayOutputStream.java:45)
>>       at  
>> org 
>> .apache.activemq.kaha.impl.index.hash.HashIndex.load(HashIndex.java: 
>> 246)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .kaha.impl.container.MapContainerImpl.load(MapContainerImpl.java:107)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .store 
>> .kahadaptor 
>> .KahaPersistenceAdapter 
>> .getSubsMapContainer(KahaPersistenceAdapter.java:222)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .store 
>> .kahadaptor 
>> .KahaReferenceStoreAdapter 
>> .createTopicReferenceStore(KahaReferenceStoreAdapter.java:171)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .store 
>> .amq 
>> .AMQPersistenceAdapter 
>> .createTopicMessageStore(AMQPersistenceAdapter.java:456)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker 
>> .region 
>> .DestinationFactoryImpl 
>> .createDestination(DestinationFactoryImpl.java:94)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.region.AbstractRegion.createDestination(AbstractRegion.java: 
>> 425)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker 
>> .jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.region.RegionBroker.addDestination(RegionBroker.java:266)
>>       at  
>> org 
>> .apache 
>> .activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
>>       at  
>> org 
>> .apache 
>> .activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java: 
>> 148)
>>       at  
>> org 
>> .apache.activemq.broker.region.RegionBroker.send(RegionBroker.java: 
>> 425)
>>       at  
>> org 
>> .apache 
>> .activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
>>       at  
>> org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker 
>> .CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
>>       at  
>> org 
>> .apache 
>> .activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java: 
>> 132)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.TransportConnection.processMessage(TransportConnection.java: 
>> 437)
>>       at  
>> org 
>> .apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java: 
>> 624)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .broker.TransportConnection.service(TransportConnection.java:292)
>>       at org.apache.activemq.broker.TransportConnection 
>> $1.onCommand(TransportConnection.java:180)
>>       at  
>> org 
>> .apache 
>> .activemq 
>> .transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104)
>>       at  
>> org 
>> .apache 
>> .activemq.transport.TransportFilter.onCommand(TransportFilter.java: 
>> 68)
>>       at  
>> org 
>> .apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java: 
>> 205)
>>       at  
>> org 
>> .apache 
>> .activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
>>       at org.apache.activemq.thread.PooledTaskRunner 
>> $1.run(PooledTaskRunner.java:43)
>>       at java.util.concurrent.ThreadPoolExecutor 
>> $Worker.runTask(ThreadPoolExecutor.java:650)
>>       at java.util.concurrent.ThreadPoolExecutor 
>> $Worker.run(ThreadPoolExecutor.java:675)
>>       at java.lang.Thread.run(Thread.java:613)
>>
>> If you run my modified test case do you still see the threading  
>> issue?
>>
>> Here's my new test case:
>>
>> package org.apache.activemq;
>>
>> import javax.jms.Connection;
>> import javax.jms.ConnectionFactory;
>> import javax.jms.Destination;
>> import javax.jms.JMSException;
>> import javax.jms.MessageProducer;
>> import javax.jms.Session;
>> import javax.jms.TextMessage;
>>
>> import junit.framework.TestCase;
>>
>> public class App extends TestCase {
>>
>>   Connection conn;
>>
>>   @Override
>>   protected void setUp() throws Exception {
>>       ConnectionFactory cf = new ActiveMQConnectionFactory("vm:// 
>> localhost");
>>       conn = cf.createConnection();
>>   }
>>
>>   @Override
>>   protected void tearDown() throws Exception {
>>       conn.close();
>>   }
>>
>>   public void testSend() throws JMSException {
>>       Session session = conn.createSession(false,  
>> Session.AUTO_ACKNOWLEDGE);
>>       MessageProducer producer = session.createProducer(null);
>>       for (int i = 0; i < 5000; i++) {
>>           Destination destination = session.createTopic("TOPIC" + i);
>>           TextMessage message = session.createTextMessage("");
>>           producer.send(destination, message);
>>           System.out.println("Sent: " + i+": "+Thread.activeCount());
>>
>>       }
>>       producer.close();
>>   }
>> }
>>
>> On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br>  
>> wrote:
>>>
>>>
>>>
>>> Hiram Chirino wrote:
>>>>
>>>> Still it would be nice if you could create a test case that shows  
>>>> the
>>>> problem and submit it so we can get to the root of the problem.
>>>>
>>>
>>> The attached code shows the problem.
>>> With UseDedicatedTaskRunner=false it works ok.
>>>
>>> http://www.nabble.com/file/p17281318/App.java App.java
>>>
>>> --
>>> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Regards,
>> Hiram
>>
>> Blog: http://hiramchirino.com
>>
>> Open Source SOA
>> http://open.iona.com
>>
>
>
>
> -- 
> Regards,
> Hiram
>
> Blog: http://hiramchirino.com
>
> Open Source SOA
> http://open.iona.com


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Looks like my memory problems are all related to the kaha HashIndex:

By the time I create 3000 queues, there are about 5000 HashIndex
object allocated.  The retained size of those HashIndex objects is
about 187 megs.  163 megs of that are just byte[]s being held directly
by the HashIndex and the DataByteArraOutputStream that the HashIndex
holds onto.

Rob, any chances of reducing the number of HashIndex (or the amount of
memory each one needs) objects held in memory?

Regards,
Hiram

On Fri, May 16, 2008 at 2:44 PM, Hiram Chirino <hi...@hiramchirino.com> wrote:
> I modified your case so that it's a JUnit test and so that it starts
> an embedded broker.. I did not see the threading problem against the
> trunk, but I did see :
>
> javax.jms.JMSException: Java heap space
>        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
>        at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1201)
>        at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1648)
>        at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
>        at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300)
>        at org.apache.activemq.App.testSend(App.java:34)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:585)
>        at junit.framework.TestCase.runTest(TestCase.java:154)
>        at junit.framework.TestCase.runBare(TestCase.java:127)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:118)
>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>        at junit.framework.TestSuite.run(TestSuite.java:203)
>        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.OutOfMemoryError: Java heap space
>        at org.apache.activemq.util.DataByteArrayOutputStream.<init>(DataByteArrayOutputStream.java:45)
>        at org.apache.activemq.kaha.impl.index.hash.HashIndex.load(HashIndex.java:246)
>        at org.apache.activemq.kaha.impl.container.MapContainerImpl.load(MapContainerImpl.java:107)
>        at org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter.getSubsMapContainer(KahaPersistenceAdapter.java:222)
>        at org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter.createTopicReferenceStore(KahaReferenceStoreAdapter.java:171)
>        at org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:456)
>        at org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94)
>        at org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425)
>        at org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
>        at org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
>        at org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266)
>        at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
>        at org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
>        at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
>        at org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148)
>        at org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425)
>        at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
>        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
>        at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
>        at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132)
>        at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437)
>        at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624)
>        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
>        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180)
>        at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104)
>        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
>        at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:205)
>        at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
>        at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>        at java.lang.Thread.run(Thread.java:613)
>
> If you run my modified test case do you still see the threading issue?
>
> Here's my new test case:
>
> package org.apache.activemq;
>
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
> import junit.framework.TestCase;
>
> public class App extends TestCase {
>
>    Connection conn;
>
>    @Override
>    protected void setUp() throws Exception {
>        ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
>        conn = cf.createConnection();
>    }
>
>    @Override
>    protected void tearDown() throws Exception {
>        conn.close();
>    }
>
>    public void testSend() throws JMSException {
>        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>        MessageProducer producer = session.createProducer(null);
>        for (int i = 0; i < 5000; i++) {
>            Destination destination = session.createTopic("TOPIC" + i);
>            TextMessage message = session.createTextMessage("");
>            producer.send(destination, message);
>            System.out.println("Sent: " + i+": "+Thread.activeCount());
>
>        }
>        producer.close();
>    }
> }
>
> On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>>
>>
>>
>> Hiram Chirino wrote:
>>>
>>> Still it would be nice if you could create a test case that shows the
>>> problem and submit it so we can get to the root of the problem.
>>>
>>
>> The attached code shows the problem.
>> With UseDedicatedTaskRunner=false it works ok.
>>
>> http://www.nabble.com/file/p17281318/App.java App.java
>>
>> --
>> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Regards,
> Hiram
>
> Blog: http://hiramchirino.com
>
> Open Source SOA
> http://open.iona.com
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by "stefan.moser" <st...@wolverton.ca>.
Hi Gary,

I don't think there is a JIRA issue.  I have just discovered that the
setting I was using for the dedicated task runner was being ignored.  I'm
running ActiveMQ as a Windows Service and I just found that there is also a
setting for the dedicated task runner in bin\win32\wrapper.conf.  I was
using dedicatedTaskRunner="false" on the broker node in conf\activemq.xml
and it was being overridden by the setting in wrapper.conf.

Now that I have the dedicated task runner turned off, the number of threads
remains low and I am able to create more topics than before.  The problem
now is that there is so much context switching going on that it has
practically ground to halt.  I'm going to try to tweak the memory settings
and see if I can get better performance.

I still haven't been able to determine what the practical limit is for the
number of topics in ActiveMQ, but so far I'm still at least an order of
magnitude under what I require.

Thanks for your help Gary.

Cheers,
Stefan



Gary Tully wrote:
> 
> Stefan,
> is there a jira issue for this, if not can you open one and capture
> the problem with a test case. Is it that even with "dedicated task
> runner"=false there is a direct correlation between the number of
> threads and the number of destinations?
> 
> Or is it that the memory usage of a destination is too high?
> 
> Would like to get to the bottom of this.
> 
> 2008/12/18 stefan.moser <st...@wolverton.ca>:
>>
>> So this issue doesn't occur in 4.1?  I might consider downgrading because
>> I
>> have no other options at this point.
>>
>> Thanks,
>> Stefan
>>
>> Danilo Tuler wrote:
>>>
>>> Hi Stefan,
>>>
>>> I'm on the same boat.
>>> I'm hitting some 4.1 issues, and I'm considering (again) to migrate to
>>> 5.2.0.
>>> But this issue is pushing me back.
>>>
>>> Danilo
>>>
>>>
>>> stefan.moser wrote:
>>>>
>>>> Has there been any progress on this issue?  I've just started using
>>>> ActiveMQ and require a large number of topics.  I am getting the same
>>>> OOME once it creates ~1000 topics.  I've tried this with v 5.0, 5.1 and
>>>> 5.2.
>>>>
>>>> Thanks,
>>>> Stefan
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21079903.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> http://blog.garytully.com
> 
> Open Source SOA
> http://FUSESource.com
> 
> 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21095619.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Gary Tully <ga...@gmail.com>.
Stefan,
is there a jira issue for this, if not can you open one and capture
the problem with a test case. Is it that even with "dedicated task
runner"=false there is a direct correlation between the number of
threads and the number of destinations?

Or is it that the memory usage of a destination is too high?

Would like to get to the bottom of this.

2008/12/18 stefan.moser <st...@wolverton.ca>:
>
> So this issue doesn't occur in 4.1?  I might consider downgrading because I
> have no other options at this point.
>
> Thanks,
> Stefan
>
> Danilo Tuler wrote:
>>
>> Hi Stefan,
>>
>> I'm on the same boat.
>> I'm hitting some 4.1 issues, and I'm considering (again) to migrate to
>> 5.2.0.
>> But this issue is pushing me back.
>>
>> Danilo
>>
>>
>> stefan.moser wrote:
>>>
>>> Has there been any progress on this issue?  I've just started using
>>> ActiveMQ and require a large number of topics.  I am getting the same
>>> OOME once it creates ~1000 topics.  I've tried this with v 5.0, 5.1 and
>>> 5.2.
>>>
>>> Thanks,
>>> Stefan
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21079903.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by "stefan.moser" <st...@wolverton.ca>.
So this issue doesn't occur in 4.1?  I might consider downgrading because I
have no other options at this point.

Thanks,
Stefan

Danilo Tuler wrote:
> 
> Hi Stefan,
> 
> I'm on the same boat.
> I'm hitting some 4.1 issues, and I'm considering (again) to migrate to
> 5.2.0.
> But this issue is pushing me back.
> 
> Danilo
> 
> 
> stefan.moser wrote:
>> 
>> Has there been any progress on this issue?  I've just started using
>> ActiveMQ and require a large number of topics.  I am getting the same
>> OOME once it creates ~1000 topics.  I've tried this with v 5.0, 5.1 and
>> 5.2.
>> 
>> Thanks,
>> Stefan
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21079903.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.
Hi Stefan,

I'm on the same boat.
I'm hitting some 4.1 issues, and I'm considering (again) to migrate to
5.2.0.
But this issue is pushing me back.

Danilo


stefan.moser wrote:
> 
> Has there been any progress on this issue?  I've just started using
> ActiveMQ and require a large number of topics.  I am getting the same OOME
> once it creates ~1000 topics.  I've tried this with v 5.0, 5.1 and 5.2.
> 
> Thanks,
> Stefan
> 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21079855.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by "stefan.moser" <st...@wolverton.ca>.
Has there been any progress on this issue?  I've just started using ActiveMQ
and require a large number of topics.  I am getting the same OOME once it
creates ~1000 topics.  I've tried this with v 5.0, 5.1 and 5.2.

Thanks,
Stefan


Danilo Tuler wrote:
> 
> Hi Hiram,
> 
> 
> Hiram Chirino wrote:
>> 
>> Please post a stack trace of all those threads that on the broker side
>> when you run this test.
> 
> I'm attaching both debug logs from the server and the client.
> The OOME stack trace is below.
> 
> INFO   | jvm 1    | 2008/05/22 23:29:01 | java.lang.OutOfMemoryError:
> unable to create new native thread
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> java.lang.Thread.start0(Native Method)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> java.lang.Thread.start(Unknown Source)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:79)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.store.amq.AMQMessageStore.<init>(AMQMessageStore.java:92)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.store.amq.AMQTopicMessageStore.<init>(AMQTopicMessageStore.java:46)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:455)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183)
> INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at java.lang.Thread.run(Unknown
> Source)
>  http://www.nabble.com/file/p17417715/server.log server.log 
> http://www.nabble.com/file/p17417715/amq-log.zip amq-log.zip 
> 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441p21079507.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.
Hi Hiram,


Hiram Chirino wrote:
> 
> Please post a stack trace of all those threads that on the broker side
> when you run this test.

I'm attaching both debug logs from the server and the client.
The OOME stack trace is below.

INFO   | jvm 1    | 2008/05/22 23:29:01 | java.lang.OutOfMemoryError: unable
to create new native thread
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at java.lang.Thread.start0(Native
Method)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at java.lang.Thread.start(Unknown
Source)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:79)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.store.amq.AMQMessageStore.<init>(AMQMessageStore.java:92)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.store.amq.AMQTopicMessageStore.<init>(AMQTopicMessageStore.java:46)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:455)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183)
INFO   | jvm 1    | 2008/05/22 23:29:01 | 	at java.lang.Thread.run(Unknown
Source)
http://www.nabble.com/file/p17417715/server.log server.log 
http://www.nabble.com/file/p17417715/amq-log.zip amq-log.zip 
-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17417715.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Please post a stack trace of all those threads that on the broker side
when you run this test.  It would help us tremendously in figuring out
the problem.  and BTW I do think it's a problem.

On Thu, May 22, 2008 at 2:40 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>
> Hi Filip,
>
>
> Filip Hanik - Dev Lists wrote:
>>
>> in the test case provided, the program is trying to create 5000+
>> connections/sessions, hence that would require 5000 threads, not very
>> scalable.
>
> No, the program is not creating 5000+ connections/sessions. There is a
> single connection and session.
> The program is sending messages to 5000+ topics (using a single connection
> and session).
>
> And that produces 5000+ threads on the server, not on the (client) program.
> And worse, those threads are kept alive forever, even when the client is
> shutdown. And there are no consumers.
>
> IMHO that sounds like a thread leak, but maybe I'm wrong...
>
> Best regards,
> Danilo
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17410886.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Danilo Tuler wrote:
> Hi Filip,
>
>
> Filip Hanik - Dev Lists wrote:
>   
>> in the test case provided, the program is trying to create 5000+ 
>> connections/sessions, hence that would require 5000 threads, not very 
>> scalable.
>>     
>
> No, the program is not creating 5000+ connections/sessions. There is a
> single connection and session.
> The program is sending messages to 5000+ topics (using a single connection
> and session).
>
> And that produces 5000+ threads on the server, not on the (client) program.
> And worse, those threads are kept alive forever, even when the client is
> shutdown. And there are no consumers.
>
> IMHO that sounds like a thread leak, but maybe I'm wrong...
>   
it's not a leak if it is configurable

Filip
> Best regards,
> Danilo
>
>   


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.
Hi Filip,


Filip Hanik - Dev Lists wrote:
> 
> in the test case provided, the program is trying to create 5000+ 
> connections/sessions, hence that would require 5000 threads, not very 
> scalable.

No, the program is not creating 5000+ connections/sessions. There is a
single connection and session.
The program is sending messages to 5000+ topics (using a single connection
and session).

And that produces 5000+ threads on the server, not on the (client) program.
And worse, those threads are kept alive forever, even when the client is
shutdown. And there are no consumers.

IMHO that sounds like a thread leak, but maybe I'm wrong...

Best regards,
Danilo

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17410886.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Danilo Tuler wrote:
> Hi Filip,
>
>
> Filip Hanik - Dev Lists wrote:
>   
>> essentially, it's more of a tuning thingy then a memory leak, if one 
>> needs that many topics/queues, then not running with the dedicated task 
>> runner sounds like the solution,
>>
>>     
>
> I didn't understand why you classify this issue as a "tuning thingy" and not
> a bug.
>   
no problem, let me see if I can explain it better.
from my understanding, UseDedicatedTaskRunner creates a thread per 
session (or connection, I would have to check).

in the test case provided, the program is trying to create 5000+ 
connections/sessions, hence that would require 5000 threads, not very 
scalable.

so to "tune" this, one would turn off the dedicated task runner, and 
that solves the problem.

If one insisted on having 5000 threads, then one would carefully have to 
tune -Xmx (lower it) and -Xss (lower it) to be able to fit that many 
threads in the JVM, I suspect the test case ran in a 32 bit JVM where 
you have a fixed size of the process heap. And raising the -Xmx flag 
will lower the number of threads you can run in the JVM


> I guess I don't know AMQ internals enough to get that.
> All I know about AMQ thread handling is what I read from [1], which may
> refer to AMQ 4.x.
>
> Where can I find documentation for the UseDedicatedTaskRunner property?
>   
source code? prolly not what you wanna hear

Filip
> Thanks,
> Danilo
>
>
> [1]
> http://open.iona.com/wiki/display/ProdInfo/Understanding+the+Threads+Allocated+in+ActiveMQ
>
>   


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.
Hi Filip,


Filip Hanik - Dev Lists wrote:
> 
> essentially, it's more of a tuning thingy then a memory leak, if one 
> needs that many topics/queues, then not running with the dedicated task 
> runner sounds like the solution,
> 

I didn't understand why you classify this issue as a "tuning thingy" and not
a bug.
I guess I don't know AMQ internals enough to get that.
All I know about AMQ thread handling is what I read from [1], which may
refer to AMQ 4.x.

Where can I find documentation for the UseDedicatedTaskRunner property?

Thanks,
Danilo


[1]
http://open.iona.com/wiki/display/ProdInfo/Understanding+the+Threads+Allocated+in+ActiveMQ

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17397291.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
essentially, it's more of a tuning thingy then a memory leak, if one 
needs that many topics/queues, then not running with the dedicated task 
runner sounds like the solution,

Filip

Filip Hanik - Dev Lists wrote:
> so it seems there are two OOME problems
>
> either you hit java heap space error, or if you have increased your 
> -Xmx very high, you'll run into OOME caused by not enough mem for the 
> number of threads it tries to create.
>
> the two errors are directly related to each other, increasing -Xmx 
> (java heap) will effectively reduce the amount of memory for thread 
> stacks
>
> in the test case provided, that assumes it tries to create a thread 
> for each topic, in his case, 5000 threads, on 32bit windows, all I 
> have to do is set -Xmx1024m which will limit my thread count to less 
> than 5000, and you'll see the error "unable to create native thread"
>
> Filip
>
> Hiram Chirino wrote:
>> I modified your case so that it's a JUnit test and so that it starts
>> an embedded broker.. I did not see the threading problem against the
>> trunk, but I did see :
>>
>> javax.jms.JMSException: Java heap space
>>     at 
>> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49) 
>>
>>     at 
>> org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1201) 
>>
>>     at 
>> org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1648)
>>     at 
>> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227) 
>>
>>     at 
>> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300) 
>>
>>     at org.apache.activemq.App.testSend(App.java:34)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>     at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>     at java.lang.reflect.Method.invoke(Method.java:585)
>>     at junit.framework.TestCase.runTest(TestCase.java:154)
>>     at junit.framework.TestCase.runBare(TestCase.java:127)
>>     at junit.framework.TestResult$1.protect(TestResult.java:106)
>>     at junit.framework.TestResult.runProtected(TestResult.java:124)
>>     at junit.framework.TestResult.run(TestResult.java:109)
>>     at junit.framework.TestCase.run(TestCase.java:118)
>>     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>     at junit.framework.TestSuite.run(TestSuite.java:203)
>>     at 
>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) 
>>
>>     at 
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
>>
>>     at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) 
>>
>>     at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) 
>>
>>     at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) 
>>
>>     at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 
>>
>> Caused by: java.lang.OutOfMemoryError: Java heap space
>>     at 
>> org.apache.activemq.util.DataByteArrayOutputStream.<init>(DataByteArrayOutputStream.java:45) 
>>
>>     at 
>> org.apache.activemq.kaha.impl.index.hash.HashIndex.load(HashIndex.java:246) 
>>
>>     at 
>> org.apache.activemq.kaha.impl.container.MapContainerImpl.load(MapContainerImpl.java:107) 
>>
>>     at 
>> org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter.getSubsMapContainer(KahaPersistenceAdapter.java:222) 
>>
>>     at 
>> org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter.createTopicReferenceStore(KahaReferenceStoreAdapter.java:171) 
>>
>>     at 
>> org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:456) 
>>
>>     at 
>> org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94) 
>>
>>     at 
>> org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425) 
>>
>>     at 
>> org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56) 
>>
>>     at 
>> org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120) 
>>
>>     at 
>> org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266) 
>>
>>     at 
>> org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141) 
>>
>>     at 
>> org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147) 
>>
>>     at 
>> org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141) 
>>
>>     at 
>> org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148) 
>>
>>     at 
>> org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425) 
>>
>>     at 
>> org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224) 
>>
>>     at 
>> org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
>>     at 
>> org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95) 
>>
>>     at 
>> org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132) 
>>
>>     at 
>> org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437) 
>>
>>     at 
>> org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624) 
>>
>>     at 
>> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292) 
>>
>>     at 
>> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180) 
>>
>>     at 
>> org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104) 
>>
>>     at 
>> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68) 
>>
>>     at 
>> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:205) 
>>
>>     at 
>> org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122) 
>>
>>     at 
>> org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43) 
>>
>>     at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) 
>>
>>     at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) 
>>
>>     at java.lang.Thread.run(Thread.java:613)
>>
>> If you run my modified test case do you still see the threading issue?
>>
>> Here's my new test case:
>>
>> package org.apache.activemq;
>>
>> import javax.jms.Connection;
>> import javax.jms.ConnectionFactory;
>> import javax.jms.Destination;
>> import javax.jms.JMSException;
>> import javax.jms.MessageProducer;
>> import javax.jms.Session;
>> import javax.jms.TextMessage;
>>
>> import junit.framework.TestCase;
>>
>> public class App extends TestCase {
>>
>>     Connection conn;
>>
>>     @Override
>>     protected void setUp() throws Exception {
>>         ConnectionFactory cf = new 
>> ActiveMQConnectionFactory("vm://localhost");
>>         conn = cf.createConnection();
>>     }
>>
>>     @Override
>>     protected void tearDown() throws Exception {
>>         conn.close();
>>     }
>>
>>     public void testSend() throws JMSException {
>>         Session session = conn.createSession(false, 
>> Session.AUTO_ACKNOWLEDGE);
>>         MessageProducer producer = session.createProducer(null);
>>         for (int i = 0; i < 5000; i++) {
>>             Destination destination = session.createTopic("TOPIC" + i);
>>             TextMessage message = session.createTextMessage("");
>>             producer.send(destination, message);
>>             System.out.println("Sent: " + i+": "+Thread.activeCount());
>>
>>         }
>>         producer.close();
>>     }
>> }
>>
>> On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br> 
>> wrote:
>>  
>>>
>>> Hiram Chirino wrote:
>>>    
>>>> Still it would be nice if you could create a test case that shows the
>>>> problem and submit it so we can get to the root of the problem.
>>>>
>>>>       
>>> The attached code shows the problem.
>>> With UseDedicatedTaskRunner=false it works ok.
>>>
>>> http://www.nabble.com/file/p17281318/App.java App.java
>>>
>>> -- 
>>> View this message in context: 
>>> http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html 
>>>
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>>     
>>
>>
>>
>>   
>
>
>


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
so it seems there are two OOME problems

either you hit java heap space error, or if you have increased your -Xmx 
very high, you'll run into OOME caused by not enough mem for the number 
of threads it tries to create.

the two errors are directly related to each other, increasing -Xmx (java 
heap) will effectively reduce the amount of memory for thread stacks

in the test case provided, that assumes it tries to create a thread for 
each topic, in his case, 5000 threads, on 32bit windows, all I have to 
do is set -Xmx1024m which will limit my thread count to less than 5000, 
and you'll see the error "unable to create native thread"

Filip

Hiram Chirino wrote:
> I modified your case so that it's a JUnit test and so that it starts
> an embedded broker.. I did not see the threading problem against the
> trunk, but I did see :
>
> javax.jms.JMSException: Java heap space
> 	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
> 	at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1201)
> 	at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1648)
> 	at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
> 	at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300)
> 	at org.apache.activemq.App.testSend(App.java:34)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.OutOfMemoryError: Java heap space
> 	at org.apache.activemq.util.DataByteArrayOutputStream.<init>(DataByteArrayOutputStream.java:45)
> 	at org.apache.activemq.kaha.impl.index.hash.HashIndex.load(HashIndex.java:246)
> 	at org.apache.activemq.kaha.impl.container.MapContainerImpl.load(MapContainerImpl.java:107)
> 	at org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter.getSubsMapContainer(KahaPersistenceAdapter.java:222)
> 	at org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter.createTopicReferenceStore(KahaReferenceStoreAdapter.java:171)
> 	at org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:456)
> 	at org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94)
> 	at org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425)
> 	at org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
> 	at org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
> 	at org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266)
> 	at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
> 	at org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
> 	at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
> 	at org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148)
> 	at org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425)
> 	at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
> 	at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
> 	at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
> 	at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132)
> 	at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437)
> 	at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624)
> 	at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
> 	at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180)
> 	at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104)
> 	at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
> 	at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:205)
> 	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
> 	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> 	at java.lang.Thread.run(Thread.java:613)
>
> If you run my modified test case do you still see the threading issue?
>
> Here's my new test case:
>
> package org.apache.activemq;
>
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
> import junit.framework.TestCase;
>
> public class App extends TestCase {
>
>     Connection conn;
>
>     @Override
>     protected void setUp() throws Exception {
>         ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
>         conn = cf.createConnection();
>     }
>
>     @Override
>     protected void tearDown() throws Exception {
>         conn.close();
>     }
>
>     public void testSend() throws JMSException {
>         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>         MessageProducer producer = session.createProducer(null);
>         for (int i = 0; i < 5000; i++) {
>             Destination destination = session.createTopic("TOPIC" + i);
>             TextMessage message = session.createTextMessage("");
>             producer.send(destination, message);
>             System.out.println("Sent: " + i+": "+Thread.activeCount());
>
>         }
>         producer.close();
>     }
> }
>
> On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>   
>>
>> Hiram Chirino wrote:
>>     
>>> Still it would be nice if you could create a test case that shows the
>>> problem and submit it so we can get to the root of the problem.
>>>
>>>       
>> The attached code shows the problem.
>> With UseDedicatedTaskRunner=false it works ok.
>>
>> http://www.nabble.com/file/p17281318/App.java App.java
>>
>> --
>> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>>     
>
>
>
>   


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
could you post a stack trace of your broker when it's got a alot of
threads allocated?  Thx.

On Fri, May 16, 2008 at 3:51 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>
>
>
> Hiram Chirino wrote:
>>
>> I modified your case so that it's a JUnit test and so that it starts
>> an embedded broker.. I did not see the threading problem against the
>> trunk, but I did see :
>>
>> javax.jms.JMSException: Java heap space
>>
>> If you run my modified test case do you still see the threading issue?
>>
>
> Same here. Java heap space with embeddeb broker.
> And still thread issue with remote broker.
>
> ActiveMQ 5.1.0, with untouched conf files (package as downloaded).
>
> Regards,
> Danilo
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17282917.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.


Hiram Chirino wrote:
> 
> I modified your case so that it's a JUnit test and so that it starts
> an embedded broker.. I did not see the threading problem against the
> trunk, but I did see :
> 
> javax.jms.JMSException: Java heap space
> 
> If you run my modified test case do you still see the threading issue?
> 

Same here. Java heap space with embeddeb broker.
And still thread issue with remote broker.

ActiveMQ 5.1.0, with untouched conf files (package as downloaded).

Regards,
Danilo

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17282917.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
I modified your case so that it's a JUnit test and so that it starts
an embedded broker.. I did not see the threading problem against the
trunk, but I did see :

javax.jms.JMSException: Java heap space
	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
	at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1201)
	at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1648)
	at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
	at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300)
	at org.apache.activemq.App.testSend(App.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.OutOfMemoryError: Java heap space
	at org.apache.activemq.util.DataByteArrayOutputStream.<init>(DataByteArrayOutputStream.java:45)
	at org.apache.activemq.kaha.impl.index.hash.HashIndex.load(HashIndex.java:246)
	at org.apache.activemq.kaha.impl.container.MapContainerImpl.load(MapContainerImpl.java:107)
	at org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter.getSubsMapContainer(KahaPersistenceAdapter.java:222)
	at org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter.createTopicReferenceStore(KahaReferenceStoreAdapter.java:171)
	at org.apache.activemq.store.amq.AMQPersistenceAdapter.createTopicMessageStore(AMQPersistenceAdapter.java:456)
	at org.apache.activemq.broker.region.DestinationFactoryImpl.createDestination(DestinationFactoryImpl.java:94)
	at org.apache.activemq.broker.region.AbstractRegion.createDestination(AbstractRegion.java:425)
	at org.apache.activemq.broker.jmx.ManagedTopicRegion.createDestination(ManagedTopicRegion.java:56)
	at org.apache.activemq.broker.region.AbstractRegion.addDestination(AbstractRegion.java:120)
	at org.apache.activemq.broker.region.RegionBroker.addDestination(RegionBroker.java:266)
	at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
	at org.apache.activemq.advisory.AdvisoryBroker.addDestination(AdvisoryBroker.java:147)
	at org.apache.activemq.broker.BrokerFilter.addDestination(BrokerFilter.java:141)
	at org.apache.activemq.broker.MutableBrokerFilter.addDestination(MutableBrokerFilter.java:148)
	at org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:425)
	at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:224)
	at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:125)
	at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:95)
	at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:132)
	at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:437)
	at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:624)
	at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
	at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180)
	at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104)
	at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
	at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:205)
	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	at java.lang.Thread.run(Thread.java:613)

If you run my modified test case do you still see the threading issue?

Here's my new test case:

package org.apache.activemq;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import junit.framework.TestCase;

public class App extends TestCase {

    Connection conn;

    @Override
    protected void setUp() throws Exception {
        ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
        conn = cf.createConnection();
    }

    @Override
    protected void tearDown() throws Exception {
        conn.close();
    }

    public void testSend() throws JMSException {
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(null);
        for (int i = 0; i < 5000; i++) {
            Destination destination = session.createTopic("TOPIC" + i);
            TextMessage message = session.createTextMessage("");
            producer.send(destination, message);
            System.out.println("Sent: " + i+": "+Thread.activeCount());

        }
        producer.close();
    }
}

On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>
>
>
> Hiram Chirino wrote:
>>
>> Still it would be nice if you could create a test case that shows the
>> problem and submit it so we can get to the root of the problem.
>>
>
> The attached code shows the problem.
> With UseDedicatedTaskRunner=false it works ok.
>
> http://www.nabble.com/file/p17281318/App.java App.java
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
BTW you tested this against 5.1 right?

On Fri, May 16, 2008 at 2:29 PM, Danilo Tuler <tu...@ideais.com.br> wrote:
>
>
>
> Hiram Chirino wrote:
>>
>> Still it would be nice if you could create a test case that shows the
>> problem and submit it so we can get to the root of the problem.
>>
>
> The attached code shows the problem.
> With UseDedicatedTaskRunner=false it works ok.
>
> http://www.nabble.com/file/p17281318/App.java App.java
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.


Hiram Chirino wrote:
> 
> Still it would be nice if you could create a test case that shows the
> problem and submit it so we can get to the root of the problem.
> 

The attached code shows the problem.
With UseDedicatedTaskRunner=false it works ok.

http://www.nabble.com/file/p17281318/App.java App.java 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17281318.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Enabling that enables thread pooling.  It just increases context
switching a bit.

Still it would be nice if you could create a test case that shows the
problem and submit it so we can get to the root of the problem.

Regards,
Hiram

On Thu, May 15, 2008 at 5:54 PM, Sridhar2008 <ac...@komandur.com> wrote:
>
>
> Hi Hiram,
>
> We were having similar issue and  confirmed the following
> (-Dorg.apache.activemq.UseDedicatedTaskRunner=false) works for us.
>
> What are the implications of doing this ?
>
> Thanks
> - Sridhar
>
>
> Hiram Chirino wrote:
>>
>> Could you try updating your activemq startup script so that instead of:
>> ACTIVEMQ_OPTS="-Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true"
>> it reads as:
>> ACTIVEMQ_OPTS="-Xmx512M
>> -Dorg.apache.activemq.UseDedicatedTaskRunner=false"
>>
>> I think that should help with your thread usage issues.
>>
>>
>> On Tue, May 13, 2008 at 9:03 AM, Danilo Tuler <tu...@ideais.com.br> wrote:
>>>
>>> Hi,
>>>
>>> I have this problem too. It happens with AMQ 5.0.0 and 5.1.0. Works fine
>>> with 4.1.1 and 4.1.2.
>>> I can see the number of threads using the windows task manager, and it's
>>> not
>>> good :-) +2000 threads.
>>>
>>> My client application is a producer, and it sends thousands of messages
>>> to
>>> thousands of differents topics. There are no subscribers to those topics.
>>> Async send is set to false. Even when the client application is shutdown
>>> the
>>> threads are kept alive.
>>>
>>> There is surely a thread leak, and maybe there is a direct relationship
>>> with
>>> the number of topics created.
>>>
>>> I've read several topics here, JIRA issues, and an article about AMQ
>>> thread
>>> handling, but did not come out with a clue.
>>>
>>> Best regards,
>>> Danilo
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17207910.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Regards,
>> Hiram
>>
>> Blog: http://hiramchirino.com
>>
>> Open Source SOA
>> http://open.iona.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17263408.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Sridhar2008 <ac...@komandur.com>.

Hi Hiram,

We were having similar issue and  confirmed the following
(-Dorg.apache.activemq.UseDedicatedTaskRunner=false) works for us.

What are the implications of doing this ? 

Thanks
- Sridhar


Hiram Chirino wrote:
> 
> Could you try updating your activemq startup script so that instead of:
> ACTIVEMQ_OPTS="-Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true"
> it reads as:
> ACTIVEMQ_OPTS="-Xmx512M
> -Dorg.apache.activemq.UseDedicatedTaskRunner=false"
> 
> I think that should help with your thread usage issues.
> 
> 
> On Tue, May 13, 2008 at 9:03 AM, Danilo Tuler <tu...@ideais.com.br> wrote:
>>
>> Hi,
>>
>> I have this problem too. It happens with AMQ 5.0.0 and 5.1.0. Works fine
>> with 4.1.1 and 4.1.2.
>> I can see the number of threads using the windows task manager, and it's
>> not
>> good :-) +2000 threads.
>>
>> My client application is a producer, and it sends thousands of messages
>> to
>> thousands of differents topics. There are no subscribers to those topics.
>> Async send is set to false. Even when the client application is shutdown
>> the
>> threads are kept alive.
>>
>> There is surely a thread leak, and maybe there is a direct relationship
>> with
>> the number of topics created.
>>
>> I've read several topics here, JIRA issues, and an article about AMQ
>> thread
>> handling, but did not come out with a clue.
>>
>> Best regards,
>> Danilo
>>
>> --
>> View this message in context:
>> http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17207910.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Regards,
> Hiram
> 
> Blog: http://hiramchirino.com
> 
> Open Source SOA
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17263408.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Could you try updating your activemq startup script so that instead of:
ACTIVEMQ_OPTS="-Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true"
it reads as:
ACTIVEMQ_OPTS="-Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=false"

I think that should help with your thread usage issues.


On Tue, May 13, 2008 at 9:03 AM, Danilo Tuler <tu...@ideais.com.br> wrote:
>
> Hi,
>
> I have this problem too. It happens with AMQ 5.0.0 and 5.1.0. Works fine
> with 4.1.1 and 4.1.2.
> I can see the number of threads using the windows task manager, and it's not
> good :-) +2000 threads.
>
> My client application is a producer, and it sends thousands of messages to
> thousands of differents topics. There are no subscribers to those topics.
> Async send is set to false. Even when the client application is shutdown the
> threads are kept alive.
>
> There is surely a thread leak, and maybe there is a direct relationship with
> the number of topics created.
>
> I've read several topics here, JIRA issues, and an article about AMQ thread
> handling, but did not come out with a clue.
>
> Best regards,
> Danilo
>
> --
> View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17207910.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by rajdavies <ra...@gmail.com>.

Could you submit a test case - I've tried to reproduce from your description
- but with no success

cheers,

Rob
-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17257710.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Danilo Tuler <tu...@ideais.com.br>.
Hi,

I have this problem too. It happens with AMQ 5.0.0 and 5.1.0. Works fine
with 4.1.1 and 4.1.2.
I can see the number of threads using the windows task manager, and it's not
good :-) +2000 threads.

My client application is a producer, and it sends thousands of messages to
thousands of differents topics. There are no subscribers to those topics.
Async send is set to false. Even when the client application is shutdown the
threads are kept alive.

There is surely a thread leak, and maybe there is a direct relationship with
the number of topics created.

I've read several topics here, JIRA issues, and an article about AMQ thread
handling, but did not come out with a clue.

Best regards,
Danilo

-- 
View this message in context: http://www.nabble.com/java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-on-AMQ-5.0-tp17005441s2354p17207910.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
I'm talking about the mem settings for the JVM that gets the OOME

in the settings below, I would remove the -Xmn flag, and let the JVM 
size the new generation itself
Also, lower -Xmx800m, and if there is a heap space OOME problem, that 
will occur before the "unable to create new native thread", if you still 
get the "unable to create...." then there could be a thread leak, do a 
thread dump, so that we can see how many threads are created on your system


Filip

Michele Mazzucco wrote:
> Filip,
>
> are you talking about the broker or the client? The settings below are 
> for the broker.
>
> Michele
>
> On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:
>
>>>>> -Xms512m -Xmx1024m -Xmn500m
>
>
>


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Michele Mazzucco <mi...@gmail.com>.
Filip,

are you talking about the broker or the client? The settings below  
are for the broker.

Michele

On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:

>>>> -Xms512m -Xmx1024m -Xmn500m


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Michele Mazzucco <mi...@gmail.com>.
Hi Jamie,

thanks for your reply. Unfortunately the HeapDumpOnOutOfMemoryError  
options works only when the OOME is due to heap space problems, not  
when the system is unable to create new threads [1].


Michele

[1] http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/ 
gdaog.html#gbzrr


On 2 May 2008, at 10:13, Jamie McCrindle wrote:

> If you can use Java 6, try the following setting:
>
> -XX:+HeapDumpOnOutOfMemoryError
>
> (and -XX:HeapDumpPath if you want the dump to go somewhere specific)
>
> This will give you a heap dump which should help a _lot_ to diagnose
> the problem. I'd recommend checking out the Memory Analyzer plugin for
> Eclipse, or failing that, you can use "jhat" which comes with Java 6.
>
> cheers,
> j.
>
> On Fri, May 2, 2008 at 9:52 AM, Michele Mazzucco
> <mi...@gmail.com> wrote:
>>
>>  On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:
>>
>>
>>> Michele Mazzucco wrote:
>>>
>>>> Filip,
>>>>
>>>> if you mean on the client side, I have a thread pool configured to
>>>> create max 100 threads.
>>>>
>>>>
>>> there could still be a thread leak in your application somewhere
>>>
>>
>>  No, there's no leak on  my client app. It's a very simple  
>> benchmark for my
>> server. BTW, how would you explain the error occurring on AMQ?
>>
>>
>>>
>>>
>>>> about -Xmx, that's the maximum amount of memory. Why are you  
>>>> telling
>>>> me that by decreasing that value there would be more space for
>>>> threads?
>>>>
>>>>
>>> cause, threads use memory, and that memory is not part of the  
>>> Java Heap,
>> and the JVM reserves memory for your java heap based on your -Xmx  
>> setting.
>>>
>>
>>  Oh, you mean the thread stack, don't you? I'll try to decrease  
>> the stack
>> size to see what happens, even if I don't think that's the root.
>>  Instead, the problem might occur because every time the run()  
>> method is
>> invoked a new session is created (and destroyed). How does AMQ  
>> deal with
>> this?, I think a thread is associated to each session, isn't it ?
>>  I'll try to store the session into a thread local.
>>
>>
>>
>>  Michele
>>
>>
>>
>>
>>>
>>> take a look at the "Inside the Java Virtual Machine" webinar at
>>> http://www.covalent.net/services/training/webinars.html
>>>
>>> it's recorded, and you'll learn how java memory management works
>>>
>>> Filip
>>>
>>>> Michele
>>>>
>>>>
>>>> On Thu, May 1, 2008 at 7:50 PM, Filip Hanik - Dev Lists
>>>> <de...@hanik.com> wrote:
>>>>
>>>>
>>>>> when it happens, do a thread dump to make sure you don't have a  
>>>>> thread
>> leak
>>>>> (too many threads)
>>>>>
>>>>>  then lower your -Xmx setting, this will make more room in the  
>>>>> JVM for
>>>>> threads,
>>>>>
>>>>>  Filip
>>>>>
>>>>>
>>>>>
>>>>>  Michele Mazzucco wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I'm facing the following error while using AMQ 5.0
>>>>>>
>>>>>> ERROR efaultMessageListenerContainer - Setup of JMS message  
>>>>>> listener
>>>>>> invoker failed - trying to recover
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>>       at java.lang.Thread.start0(Native Method)
>>>>>>       at java.lang.Thread.start(Thread.java:574)
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.thread.DedicatedTaskRunner.<init> 
>> (DedicatedTaskRunner.java:42)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner 
>> (TaskRunnerFactory.java:74)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQSessionExecutor.wakeup 
>> (ActiveMQSessionExecutor.java:92)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQMessageConsumer.start 
>> (ActiveMQMessageConsumer.java:993)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQMessageConsumer.<init> 
>> (ActiveMQMessageConsumer.java:222)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQSession.createConsumer 
>> (ActiveMQSession.java:1004)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQSession.createConsumer 
>> (ActiveMQSession.java:948)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQSession.createConsumer 
>> (ActiveMQSession.java:861)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContai 
>> ner.createConsumer(AbstractPollingMessageListenerContainer.java:437)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContai 
>> ner.createListenerConsumer 
>> (AbstractPollingMessageListenerContainer.java:216)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContai 
>> ner.doReceiveAndExecute 
>> (AbstractPollingMessageListenerContainer.java:297)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContai 
>> ner.receiveAndExecute(AbstractPollingMessageListenerContainer.java: 
>> 254)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $AsyncMessageListenerInvoker.invokeListener 
>> (DefaultMessageListenerContainer.java:871)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $AsyncMessageListenerInvoker.run 
>> (DefaultMessageListenerContainer.java:818)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>> Exception in thread "DefaultMessageListenerContainer-29"
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>>       at java.lang.Thread.start0(Native Method)
>>>>>>       at java.lang.Thread.start(Thread.java:574)
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportThreadSupport.doStart 
>> (TransportThreadSupport.java:43)ERROR
>>>>>
>>>>>
>>>>>> Service                        - Async error occurred:
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>>       at java.lang.Thread.start0(Native Method)
>>>>>>       at java.lang.Thread.start(Thread.java:574)
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection.processShutdown 
>> (TransportConnection.java:326)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>> org.apache.activemq.command.ShutdownInfo.visit 
>>>>> (ShutdownInfo.java:35)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection.service 
>> (TransportConnection.java:281)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection$1.onCommand 
>> (TransportConnection.java:178)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.onCommand 
>> (TransportFilter.java:67)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.WireFormatNegotiator.onCommand 
>> (WireFormatNegotiator.java:134)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.InactivityMonitor.onCommand 
>> (InactivityMonitor.java:138)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportSupport.doConsume 
>> (TransportSupport.java:83)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransport.doRun 
>> (TcpTransport.java:185)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransport.run 
>> (TcpTransport.java:172)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransport.doStart 
>> (TcpTransport.java:368)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>> org.apache.activemq.util.ServiceSupport.start 
>>>>> (ServiceSupport.java:48)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.start 
>> (TransportFilter.java:56)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.start 
>> (TransportFilter.java:56)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.WireFormatNegotiator.start 
>> (WireFormatNegotiator.java:63)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.start 
>> (TransportFilter.java:56)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.start 
>> (TransportFilter.java:56)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio 
>> n(ActiveMQConnectionFactory.java:256)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio 
>> n(ActiveMQConnectionFactory.java:220)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection 
>> (ActiveMQConnectionFactory.java:168)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.support.JmsAccessor.createConnection 
>> (JmsAccessor.java:188)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractJmsListeningContainer.create 
>> SharedConnection(AbstractJmsListeningContainer.java:209)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.AbstractJmsListeningContainer.refres 
>> hSharedConnection(AbstractJmsListeningContainer.java:197)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer.refr 
>> eshConnectionUntilSuccessful(DefaultMessageListenerContainer.java: 
>> 701)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer.reco 
>> verAfterListenerSetupFailure(DefaultMessageListenerContainer.java: 
>> 683)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>> $AsyncMessageListenerInvoker.run 
>> (DefaultMessageListenerContainer.java:835)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>> Exception in thread "ActiveMQ Transport Server:
>> tcp://localhost:61616"
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>>       at java.lang.Thread.start0(Native Method)
>>>>>>       at java.lang.Thread.start(Thread.java:574)
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnector$1.onAccept 
>> (TransportConnector.java:160)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransportServer.run 
>> (TcpTransportServer.java:213)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>> ERROR Service                        - Async error occurred:
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>>>       at java.lang.Thread.start0(Native Method)
>>>>>>       at java.lang.Thread.start(Thread.java:574)
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection.processShutdown 
>> (TransportConnection.java:326)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>> org.apache.activemq.command.ShutdownInfo.visit 
>>>>> (ShutdownInfo.java:35)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection.service 
>> (TransportConnection.java:281)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.broker.TransportConnection$1.onCommand 
>> (TransportConnection.java:178)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportFilter.onCommand 
>> (TransportFilter.java:67)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.WireFormatNegotiator.onCommand 
>> (WireFormatNegotiator.java:134)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.InactivityMonitor.onCommand 
>> (InactivityMonitor.java:138)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.TransportSupport.doConsume 
>> (TransportSupport.java:83)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransport.doRun 
>> (TcpTransport.java:185)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.tcp.TcpTransport.run 
>> (TcpTransport.java:172)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>> INFO  BrokerService                  - ActiveMQ Message Broker
>>>>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is  
>>>>>> shutting
>>>>>> down
>>>>>> INFO  NetworkConnector               - Network Connector
>>>>>>
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryA 
>> gent@17c96a9
>>>>>
>>>>>
>>>>>> Stopped
>>>>>> INFO  TransportConnector             - Connector openwire Stopped
>>>>>> INFO  TransportConnector             - Connector vm://localhost
>> Stopped
>>>>>> WARN  ActiveMQConnection             - Async exception with no
>>>>>> exception listener:
>>>>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>>>>> (vm://localhost#1) disposed.
>>>>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>>>>> (vm://localhost#1) disposed.
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.vm.VMTransport.iterate 
>> (VMTransport.java:200)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.thread.DedicatedTaskRunner.runTask 
>> (DedicatedTaskRunner.java:98)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.thread.DedicatedTaskRunner$1.run 
>> (DedicatedTaskRunner.java:36)
>>>>>
>>>>>
>>>>>> INFO  BrokerService                  - ActiveMQ JMS Message  
>>>>>> Broker
>>>>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
>>>>>> INFO  AdvisoryConsumer               - Failed to send remove
>> command:
>>>>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>>>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.util.JMSExceptionSupport.create 
>> (JMSExceptionSupport.java:62)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnection.asyncSendPacket 
>> (ActiveMQConnection.java:1154)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>> org.apache.activemq.AdvisoryConsumer.dispose 
>>>>> (AdvisoryConsumer.java:56)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnection.cleanup 
>> (ActiveMQConnection.java:1326)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnection.transportFailed 
>> (ActiveMQConnection.java:2027)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnection$4.run 
>> (ActiveMQConnection.java:1663)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask 
>> (ThreadPoolExecutor.java:650)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run 
>> (ThreadPoolExecutor.java:675)
>>>>>
>>>>>
>>>>>>       at java.lang.Thread.run(Thread.java:595)
>>>>>> Caused by:
>> org.apache.activemq.transport.TransportDisposedIOException:
>>>>>> Peer (vm://localhost#1) disposed.
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.vm.VMTransport.oneway 
>> (VMTransport.java:87)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.MutexTransport.oneway 
>> (MutexTransport.java:40)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.transport.ResponseCorrelator.oneway 
>> (ResponseCorrelator.java:59)
>>>>>
>>>>>
>>>>>>       at
>>>>>>
>>>>>>
>>>>>
>> org.apache.activemq.ActiveMQConnection.asyncSendPacket 
>> (ActiveMQConnection.java:1152)
>>>>>
>>>>>
>>>>>>       ... 7 more
>>>>>>
>>>>>>
>>>>>> My broker is running on a linux box with kernel 2.6 (I've read  
>>>>>> about
>>>>>> some similar issues when running on a kernel 2.4).
>>>>>> I'm using the following options when starting AMQ:
>>>>>> -Xms512m -Xmx1024m -Xmn500m
>>>>>>
>>>>>> I'm using the default configuration (no persistence).
>>>>>> I don't know whether it can help to diagnose the problem, my  
>>>>>> clients
>>>>>> are creating a lot of temporary queues (everything is cleaned up
>> after
>>>>>> use), but their lifetime is very short (a few seconds, they  
>>>>>> are just
>>>>>> used to receive a response message).
>>>>>> A similar problem occurs on my test client too (maybe it's  
>>>>>> related
>> to
>>>>>> the error on the broker), but not on the server.
>>>>>>
>>>>>>
>>>>>> Any help would be appreciated,
>>>>>> Michele
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Jamie McCrindle <ja...@imperatives.co.uk>.
If you can use Java 6, try the following setting:

-XX:+HeapDumpOnOutOfMemoryError

(and -XX:HeapDumpPath if you want the dump to go somewhere specific)

This will give you a heap dump which should help a _lot_ to diagnose
the problem. I'd recommend checking out the Memory Analyzer plugin for
Eclipse, or failing that, you can use "jhat" which comes with Java 6.

cheers,
j.

On Fri, May 2, 2008 at 9:52 AM, Michele Mazzucco
<mi...@gmail.com> wrote:
>
>  On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:
>
>
> > Michele Mazzucco wrote:
> >
> > > Filip,
> > >
> > > if you mean on the client side, I have a thread pool configured to
> > > create max 100 threads.
> > >
> > >
> > there could still be a thread leak in your application somewhere
> >
>
>  No, there's no leak on  my client app. It's a very simple benchmark for my
> server. BTW, how would you explain the error occurring on AMQ?
>
>
> >
> >
> > > about -Xmx, that's the maximum amount of memory. Why are you telling
> > > me that by decreasing that value there would be more space for
> > > threads?
> > >
> > >
> > cause, threads use memory, and that memory is not part of the Java Heap,
> and the JVM reserves memory for your java heap based on your -Xmx setting.
> >
>
>  Oh, you mean the thread stack, don't you? I'll try to decrease the stack
> size to see what happens, even if I don't think that's the root.
>  Instead, the problem might occur because every time the run() method is
> invoked a new session is created (and destroyed). How does AMQ deal with
> this?, I think a thread is associated to each session, isn't it ?
>  I'll try to store the session into a thread local.
>
>
>
>  Michele
>
>
>
>
> >
> > take a look at the "Inside the Java Virtual Machine" webinar at
> > http://www.covalent.net/services/training/webinars.html
> >
> > it's recorded, and you'll learn how java memory management works
> >
> > Filip
> >
> > > Michele
> > >
> > >
> > > On Thu, May 1, 2008 at 7:50 PM, Filip Hanik - Dev Lists
> > > <de...@hanik.com> wrote:
> > >
> > >
> > > > when it happens, do a thread dump to make sure you don't have a thread
> leak
> > > > (too many threads)
> > > >
> > > >  then lower your -Xmx setting, this will make more room in the JVM for
> > > > threads,
> > > >
> > > >  Filip
> > > >
> > > >
> > > >
> > > >  Michele Mazzucco wrote:
> > > >
> > > >
> > > >
> > > > > Hi all,
> > > > >
> > > > > I'm facing the following error while using AMQ 5.0
> > > > >
> > > > > ERROR efaultMessageListenerContainer - Setup of JMS message listener
> > > > > invoker failed - trying to recover
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > >       at java.lang.Thread.start0(Native Method)
> > > > >       at java.lang.Thread.start(Thread.java:574)
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > > Exception in thread "DefaultMessageListenerContainer-29"
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > >       at java.lang.Thread.start0(Native Method)
> > > > >       at java.lang.Thread.start(Thread.java:574)
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)ERROR
> > > >
> > > >
> > > > > Service                        - Async error occurred:
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > >       at java.lang.Thread.start0(Native Method)
> > > > >       at java.lang.Thread.start(Thread.java:574)
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > > org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > > org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > > Exception in thread "ActiveMQ Transport Server:
> tcp://localhost:61616"
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > >       at java.lang.Thread.start0(Native Method)
> > > > >       at java.lang.Thread.start(Thread.java:574)
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > > ERROR Service                        - Async error occurred:
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > > java.lang.OutOfMemoryError: unable to create new native thread
> > > > >       at java.lang.Thread.start0(Native Method)
> > > > >       at java.lang.Thread.start(Thread.java:574)
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > > org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > > INFO  BrokerService                  - ActiveMQ Message Broker
> > > > > (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is shutting
> > > > > down
> > > > > INFO  NetworkConnector               - Network Connector
> > > > >
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@17c96a9
> > > >
> > > >
> > > > > Stopped
> > > > > INFO  TransportConnector             - Connector openwire Stopped
> > > > > INFO  TransportConnector             - Connector vm://localhost
> Stopped
> > > > > WARN  ActiveMQConnection             - Async exception with no
> > > > > exception listener:
> > > > > org.apache.activemq.transport.TransportDisposedIOException: Peer
> > > > > (vm://localhost#1) disposed.
> > > > > org.apache.activemq.transport.TransportDisposedIOException: Peer
> > > > > (vm://localhost#1) disposed.
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:200)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)
> > > >
> > > >
> > > > > INFO  BrokerService                  - ActiveMQ JMS Message Broker
> > > > > (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
> > > > > INFO  AdvisoryConsumer               - Failed to send remove
> command:
> > > > > javax.jms.JMSException: Peer (vm://localhost#1) disposed.
> > > > > javax.jms.JMSException: Peer (vm://localhost#1) disposed.
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1154)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > > org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnection.cleanup(ActiveMQConnection.java:1326)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnection.transportFailed(ActiveMQConnection.java:2027)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnection$4.run(ActiveMQConnection.java:1663)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> > > >
> > > >
> > > > >       at java.lang.Thread.run(Thread.java:595)
> > > > > Caused by:
> org.apache.activemq.transport.TransportDisposedIOException:
> > > > > Peer (vm://localhost#1) disposed.
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:87)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:59)
> > > >
> > > >
> > > > >       at
> > > > >
> > > > >
> > > >
> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1152)
> > > >
> > > >
> > > > >       ... 7 more
> > > > >
> > > > >
> > > > > My broker is running on a linux box with kernel 2.6 (I've read about
> > > > > some similar issues when running on a kernel 2.4).
> > > > > I'm using the following options when starting AMQ:
> > > > > -Xms512m -Xmx1024m -Xmn500m
> > > > >
> > > > > I'm using the default configuration (no persistence).
> > > > > I don't know whether it can help to diagnose the problem, my clients
> > > > > are creating a lot of temporary queues (everything is cleaned up
> after
> > > > > use), but their lifetime is very short (a few seconds, they are just
> > > > > used to receive a response message).
> > > > > A similar problem occurs on my test client too (maybe it's related
> to
> > > > > the error on the broker), but not on the server.
> > > > >
> > > > >
> > > > > Any help would be appreciated,
> > > > > Michele
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Michele Mazzucco <mi...@gmail.com>.
On 2 May 2008, at 00:20, Filip Hanik - Dev Lists wrote:

> Michele Mazzucco wrote:
>> Filip,
>>
>> if you mean on the client side, I have a thread pool configured to
>> create max 100 threads.
>>
> there could still be a thread leak in your application somewhere

No, there's no leak on  my client app. It's a very simple benchmark  
for my server. BTW, how would you explain the error occurring on AMQ?
>
>> about -Xmx, that's the maximum amount of memory. Why are you telling
>> me that by decreasing that value there would be more space for
>> threads?
>>
> cause, threads use memory, and that memory is not part of the Java  
> Heap, and the JVM reserves memory for your java heap based on your - 
> Xmx setting.

Oh, you mean the thread stack, don't you? I'll try to decrease the  
stack size to see what happens, even if I don't think that's the root.
Instead, the problem might occur because every time the run() method  
is invoked a new session is created (and destroyed). How does AMQ  
deal with this?, I think a thread is associated to each session,  
isn't it ?
I'll try to store the session into a thread local.



Michele

>
> take a look at the "Inside the Java Virtual Machine" webinar at
> http://www.covalent.net/services/training/webinars.html
>
> it's recorded, and you'll learn how java memory management works
>
> Filip
>> Michele
>>
>>
>> On Thu, May 1, 2008 at 7:50 PM, Filip Hanik - Dev Lists
>> <de...@hanik.com> wrote:
>>
>>> when it happens, do a thread dump to make sure you don't have a  
>>> thread leak
>>> (too many threads)
>>>
>>>  then lower your -Xmx setting, this will make more room in the  
>>> JVM for
>>> threads,
>>>
>>>  Filip
>>>
>>>
>>>
>>>  Michele Mazzucco wrote:
>>>
>>>
>>>> Hi all,
>>>>
>>>> I'm facing the following error while using AMQ 5.0
>>>>
>>>> ERROR efaultMessageListenerContainer - Setup of JMS message  
>>>> listener
>>>> invoker failed - trying to recover
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>        at java.lang.Thread.start0(Native Method)
>>>>        at java.lang.Thread.start(Thread.java:574)
>>>>        at
>>>>
>>> org.apache.activemq.thread.DedicatedTaskRunner.<init> 
>>> (DedicatedTaskRunner.java:42)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner 
>>> (TaskRunnerFactory.java:74)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQSessionExecutor.wakeup 
>>> (ActiveMQSessionExecutor.java:92)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQMessageConsumer.start 
>>> (ActiveMQMessageConsumer.java:993)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQMessageConsumer.<init> 
>>> (ActiveMQMessageConsumer.java:222)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQSession.createConsumer 
>>> (ActiveMQSession.java:1004)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQSession.createConsumer 
>>> (ActiveMQSession.java:948)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQSession.createConsumer 
>>> (ActiveMQSession.java:861)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractPollingMessageListenerConta 
>>> iner.createConsumer(AbstractPollingMessageListenerContainer.java: 
>>> 437)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractPollingMessageListenerConta 
>>> iner.createListenerConsumer 
>>> (AbstractPollingMessageListenerContainer.java:216)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractPollingMessageListenerConta 
>>> iner.doReceiveAndExecute 
>>> (AbstractPollingMessageListenerContainer.java:297)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractPollingMessageListenerConta 
>>> iner.receiveAndExecute 
>>> (AbstractPollingMessageListenerContainer.java:254)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>>> $AsyncMessageListenerInvoker.invokeListener 
>>> (DefaultMessageListenerContainer.java:871)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>>> $AsyncMessageListenerInvoker.run 
>>> (DefaultMessageListenerContainer.java:818)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>> Exception in thread "DefaultMessageListenerContainer-29"
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>        at java.lang.Thread.start0(Native Method)
>>>>        at java.lang.Thread.start(Thread.java:574)
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportThreadSupport.doStart 
>>> (TransportThreadSupport.java:43)ERROR
>>>
>>>> Service                        - Async error occurred:
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>        at java.lang.Thread.start0(Native Method)
>>>>        at java.lang.Thread.start(Thread.java:574)
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection.processShutdown 
>>> (TransportConnection.java:326)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection.service 
>>> (TransportConnection.java:281)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection$1.onCommand 
>>> (TransportConnection.java:178)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.onCommand 
>>> (TransportFilter.java:67)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.WireFormatNegotiator.onCommand 
>>> (WireFormatNegotiator.java:134)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.InactivityMonitor.onCommand 
>>> (InactivityMonitor.java:138)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportSupport.doConsume 
>>> (TransportSupport.java:83)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransport.doRun 
>>> (TcpTransport.java:185)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransport.run 
>>> (TcpTransport.java:172)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransport.doStart 
>>> (TcpTransport.java:368)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java: 
>>> 48)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.start 
>>> (TransportFilter.java:56)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.start 
>>> (TransportFilter.java:56)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.WireFormatNegotiator.start 
>>> (WireFormatNegotiator.java:63)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.start 
>>> (TransportFilter.java:56)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.start 
>>> (TransportFilter.java:56)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnecti 
>>> on(ActiveMQConnectionFactory.java:256)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnecti 
>>> on(ActiveMQConnectionFactory.java:220)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnectionFactory.createConnection 
>>> (ActiveMQConnectionFactory.java:168)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.support.JmsAccessor.createConnection 
>>> (JmsAccessor.java:188)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractJmsListeningContainer.creat 
>>> eSharedConnection(AbstractJmsListeningContainer.java:209)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.AbstractJmsListeningContainer.refre 
>>> shSharedConnection(AbstractJmsListeningContainer.java:197)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.DefaultMessageListenerContainer.ref 
>>> reshConnectionUntilSuccessful 
>>> (DefaultMessageListenerContainer.java:701)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.DefaultMessageListenerContainer.rec 
>>> overAfterListenerSetupFailure 
>>> (DefaultMessageListenerContainer.java:683)
>>>
>>>>        at
>>>>
>>> org.springframework.jms.listener.DefaultMessageListenerContainer 
>>> $AsyncMessageListenerInvoker.run 
>>> (DefaultMessageListenerContainer.java:835)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>> Exception in thread "ActiveMQ Transport Server: tcp://localhost: 
>>>> 61616"
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>        at java.lang.Thread.start0(Native Method)
>>>>        at java.lang.Thread.start(Thread.java:574)
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnector$1.onAccept 
>>> (TransportConnector.java:160)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransportServer.run 
>>> (TcpTransportServer.java:213)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>> ERROR Service                        - Async error occurred:
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>>        at java.lang.Thread.start0(Native Method)
>>>>        at java.lang.Thread.start(Thread.java:574)
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection.processShutdown 
>>> (TransportConnection.java:326)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection.service 
>>> (TransportConnection.java:281)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.broker.TransportConnection$1.onCommand 
>>> (TransportConnection.java:178)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportFilter.onCommand 
>>> (TransportFilter.java:67)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.WireFormatNegotiator.onCommand 
>>> (WireFormatNegotiator.java:134)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.InactivityMonitor.onCommand 
>>> (InactivityMonitor.java:138)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.TransportSupport.doConsume 
>>> (TransportSupport.java:83)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransport.doRun 
>>> (TcpTransport.java:185)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.tcp.TcpTransport.run 
>>> (TcpTransport.java:172)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>> INFO  BrokerService                  - ActiveMQ Message Broker
>>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is  
>>>> shutting
>>>> down
>>>> INFO  NetworkConnector               - Network Connector
>>>>
>>>>
>>> org.apache.activemq.transport.discovery.multicast.MulticastDiscovery 
>>> Agent@17c96a9
>>>
>>>> Stopped
>>>> INFO  TransportConnector             - Connector openwire Stopped
>>>> INFO  TransportConnector             - Connector vm://localhost  
>>>> Stopped
>>>> WARN  ActiveMQConnection             - Async exception with no
>>>> exception listener:
>>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>>> (vm://localhost#1) disposed.
>>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>>> (vm://localhost#1) disposed.
>>>>        at
>>>>
>>> org.apache.activemq.transport.vm.VMTransport.iterate 
>>> (VMTransport.java:200)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.thread.DedicatedTaskRunner.runTask 
>>> (DedicatedTaskRunner.java:98)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.thread.DedicatedTaskRunner$1.run 
>>> (DedicatedTaskRunner.java:36)
>>>
>>>> INFO  BrokerService                  - ActiveMQ JMS Message Broker
>>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
>>>> INFO  AdvisoryConsumer               - Failed to send remove  
>>>> command:
>>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>>>        at
>>>>
>>> org.apache.activemq.util.JMSExceptionSupport.create 
>>> (JMSExceptionSupport.java:62)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnection.asyncSendPacket 
>>> (ActiveMQConnection.java:1154)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.AdvisoryConsumer.dispose 
>>> (AdvisoryConsumer.java:56)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnection.cleanup 
>>> (ActiveMQConnection.java:1326)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnection.transportFailed 
>>> (ActiveMQConnection.java:2027)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnection$4.run 
>>> (ActiveMQConnection.java:1663)
>>>
>>>>        at
>>>>
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask 
>>> (ThreadPoolExecutor.java:650)
>>>
>>>>        at
>>>>
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run 
>>> (ThreadPoolExecutor.java:675)
>>>
>>>>        at java.lang.Thread.run(Thread.java:595)
>>>> Caused by:  
>>>> org.apache.activemq.transport.TransportDisposedIOException:
>>>> Peer (vm://localhost#1) disposed.
>>>>        at
>>>>
>>> org.apache.activemq.transport.vm.VMTransport.oneway 
>>> (VMTransport.java:87)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.MutexTransport.oneway 
>>> (MutexTransport.java:40)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.transport.ResponseCorrelator.oneway 
>>> (ResponseCorrelator.java:59)
>>>
>>>>        at
>>>>
>>> org.apache.activemq.ActiveMQConnection.asyncSendPacket 
>>> (ActiveMQConnection.java:1152)
>>>
>>>>        ... 7 more
>>>>
>>>>
>>>> My broker is running on a linux box with kernel 2.6 (I've read  
>>>> about
>>>> some similar issues when running on a kernel 2.4).
>>>> I'm using the following options when starting AMQ:
>>>> -Xms512m -Xmx1024m -Xmn500m
>>>>
>>>> I'm using the default configuration (no persistence).
>>>> I don't know whether it can help to diagnose the problem, my  
>>>> clients
>>>> are creating a lot of temporary queues (everything is cleaned up  
>>>> after
>>>> use), but their lifetime is very short (a few seconds, they are  
>>>> just
>>>> used to receive a response message).
>>>> A similar problem occurs on my test client too (maybe it's  
>>>> related to
>>>> the error on the broker), but not on the server.
>>>>
>>>>
>>>> Any help would be appreciated,
>>>> Michele
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Michele Mazzucco wrote:
> Filip,
>
> if you mean on the client side, I have a thread pool configured to
> create max 100 threads.
>   
there could still be a thread leak in your application somewhere

> about -Xmx, that's the maximum amount of memory. Why are you telling
> me that by decreasing that value there would be more space for
> threads?
>   
cause, threads use memory, and that memory is not part of the Java Heap, 
and the JVM reserves memory for your java heap based on your -Xmx setting.

take a look at the "Inside the Java Virtual Machine" webinar at
http://www.covalent.net/services/training/webinars.html

it's recorded, and you'll learn how java memory management works

Filip
> Michele
>
>
> On Thu, May 1, 2008 at 7:50 PM, Filip Hanik - Dev Lists
> <de...@hanik.com> wrote:
>   
>> when it happens, do a thread dump to make sure you don't have a thread leak
>> (too many threads)
>>
>>  then lower your -Xmx setting, this will make more room in the JVM for
>> threads,
>>
>>  Filip
>>
>>
>>
>>  Michele Mazzucco wrote:
>>
>>     
>>> Hi all,
>>>
>>> I'm facing the following error while using AMQ 5.0
>>>
>>> ERROR efaultMessageListenerContainer - Setup of JMS message listener
>>> invoker failed - trying to recover
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>        at java.lang.Thread.start0(Native Method)
>>>        at java.lang.Thread.start(Thread.java:574)
>>>        at
>>>       
>> org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
>>     
>>>        at
>>>       
>> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>> Exception in thread "DefaultMessageListenerContainer-29"
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>        at java.lang.Thread.start0(Native Method)
>>>        at java.lang.Thread.start(Thread.java:574)
>>>        at
>>>       
>> org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)ERROR
>>     
>>> Service                        - Async error occurred:
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>        at java.lang.Thread.start0(Native Method)
>>>        at java.lang.Thread.start(Thread.java:574)
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
>>     
>>>        at
>>>       
>> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>>     
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
>>     
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>>
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
>>     
>>>        at
>>>       
>> org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
>>     
>>>        at
>>>       
>> org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
>>     
>>>        at
>>>       
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>> Exception in thread "ActiveMQ Transport Server: tcp://localhost:61616"
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>        at java.lang.Thread.start0(Native Method)
>>>        at java.lang.Thread.start(Thread.java:574)
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>> ERROR Service                        - Async error occurred:
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>> java.lang.OutOfMemoryError: unable to create new native thread
>>>        at java.lang.Thread.start0(Native Method)
>>>        at java.lang.Thread.start(Thread.java:574)
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
>>     
>>>        at
>>>       
>> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>>     
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
>>     
>>>        at
>>>       
>> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>> INFO  BrokerService                  - ActiveMQ Message Broker
>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is shutting
>>> down
>>> INFO  NetworkConnector               - Network Connector
>>>
>>>       
>> org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@17c96a9
>>     
>>> Stopped
>>> INFO  TransportConnector             - Connector openwire Stopped
>>> INFO  TransportConnector             - Connector vm://localhost Stopped
>>> WARN  ActiveMQConnection             - Async exception with no
>>> exception listener:
>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>> (vm://localhost#1) disposed.
>>> org.apache.activemq.transport.TransportDisposedIOException: Peer
>>> (vm://localhost#1) disposed.
>>>        at
>>>       
>> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:200)
>>     
>>>        at
>>>       
>> org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
>>     
>>>        at
>>>       
>> org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)
>>     
>>> INFO  BrokerService                  - ActiveMQ JMS Message Broker
>>> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
>>> INFO  AdvisoryConsumer               - Failed to send remove command:
>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>>>        at
>>>       
>> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1154)
>>     
>>>        at
>>>       
>> org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnection.cleanup(ActiveMQConnection.java:1326)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnection.transportFailed(ActiveMQConnection.java:2027)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnection$4.run(ActiveMQConnection.java:1663)
>>     
>>>        at
>>>       
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>>     
>>>        at
>>>       
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>>     
>>>        at java.lang.Thread.run(Thread.java:595)
>>> Caused by: org.apache.activemq.transport.TransportDisposedIOException:
>>> Peer (vm://localhost#1) disposed.
>>>        at
>>>       
>> org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:87)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
>>     
>>>        at
>>>       
>> org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:59)
>>     
>>>        at
>>>       
>> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1152)
>>     
>>>        ... 7 more
>>>
>>>
>>> My broker is running on a linux box with kernel 2.6 (I've read about
>>> some similar issues when running on a kernel 2.4).
>>> I'm using the following options when starting AMQ:
>>> -Xms512m -Xmx1024m -Xmn500m
>>>
>>> I'm using the default configuration (no persistence).
>>> I don't know whether it can help to diagnose the problem, my clients
>>> are creating a lot of temporary queues (everything is cleaned up after
>>> use), but their lifetime is very short (a few seconds, they are just
>>> used to receive a response message).
>>> A similar problem occurs on my test client too (maybe it's related to
>>> the error on the broker), but not on the server.
>>>
>>>
>>> Any help would be appreciated,
>>> Michele
>>>
>>>
>>>
>>>       
>>     
>
>   


Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Michele Mazzucco <mi...@gmail.com>.
Filip,

if you mean on the client side, I have a thread pool configured to
create max 100 threads.
about -Xmx, that's the maximum amount of memory. Why are you telling
me that by decreasing that value there would be more space for
threads?

Michele


On Thu, May 1, 2008 at 7:50 PM, Filip Hanik - Dev Lists
<de...@hanik.com> wrote:
> when it happens, do a thread dump to make sure you don't have a thread leak
> (too many threads)
>
>  then lower your -Xmx setting, this will make more room in the JVM for
> threads,
>
>  Filip
>
>
>
>  Michele Mazzucco wrote:
>
> > Hi all,
> >
> > I'm facing the following error while using AMQ 5.0
> >
> > ERROR efaultMessageListenerContainer - Setup of JMS message listener
> > invoker failed - trying to recover
> > java.lang.OutOfMemoryError: unable to create new native thread
> >        at java.lang.Thread.start0(Native Method)
> >        at java.lang.Thread.start(Thread.java:574)
> >        at
> org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
> >        at
> org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
> >        at
> org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
> >        at
> org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
> >        at
> org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
> >        at
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
> >        at
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
> >        at
> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
> >        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
> >        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
> >        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
> >        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
> >        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
> >        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
> >        at java.lang.Thread.run(Thread.java:595)
> > Exception in thread "DefaultMessageListenerContainer-29"
> > java.lang.OutOfMemoryError: unable to create new native thread
> >        at java.lang.Thread.start0(Native Method)
> >        at java.lang.Thread.start(Thread.java:574)
> >        at
> org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)ERROR
> > Service                        - Async error occurred:
> > java.lang.OutOfMemoryError: unable to create new native thread
> > java.lang.OutOfMemoryError: unable to create new native thread
> >        at java.lang.Thread.start0(Native Method)
> >        at java.lang.Thread.start(Thread.java:574)
> >        at
> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
> >        at
> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
> >        at
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
> >        at
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
> >        at
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
> >        at
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
> >        at
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
> >        at
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
> >        at
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
> >        at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
> >        at java.lang.Thread.run(Thread.java:595)
> >
> >        at
> org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
> >        at
> org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
> >        at
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> >        at
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> >        at
> org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
> >        at
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> >        at
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
> >        at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
> >        at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
> >        at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
> >        at
> org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
> >        at
> org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
> >        at
> org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
> >        at
> org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
> >        at
> org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
> >        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
> >        at java.lang.Thread.run(Thread.java:595)
> > Exception in thread "ActiveMQ Transport Server: tcp://localhost:61616"
> > java.lang.OutOfMemoryError: unable to create new native thread
> >        at java.lang.Thread.start0(Native Method)
> >        at java.lang.Thread.start(Thread.java:574)
> >        at
> org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
> >        at
> org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
> >        at java.lang.Thread.run(Thread.java:595)
> > ERROR Service                        - Async error occurred:
> > java.lang.OutOfMemoryError: unable to create new native thread
> > java.lang.OutOfMemoryError: unable to create new native thread
> >        at java.lang.Thread.start0(Native Method)
> >        at java.lang.Thread.start(Thread.java:574)
> >        at
> org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
> >        at
> org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
> >        at
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
> >        at
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
> >        at
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
> >        at
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
> >        at
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
> >        at
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
> >        at
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
> >        at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
> >        at java.lang.Thread.run(Thread.java:595)
> > INFO  BrokerService                  - ActiveMQ Message Broker
> > (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is shutting
> > down
> > INFO  NetworkConnector               - Network Connector
> >
> org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@17c96a9
> > Stopped
> > INFO  TransportConnector             - Connector openwire Stopped
> > INFO  TransportConnector             - Connector vm://localhost Stopped
> > WARN  ActiveMQConnection             - Async exception with no
> > exception listener:
> > org.apache.activemq.transport.TransportDisposedIOException: Peer
> > (vm://localhost#1) disposed.
> > org.apache.activemq.transport.TransportDisposedIOException: Peer
> > (vm://localhost#1) disposed.
> >        at
> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:200)
> >        at
> org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
> >        at
> org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)
> > INFO  BrokerService                  - ActiveMQ JMS Message Broker
> > (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
> > INFO  AdvisoryConsumer               - Failed to send remove command:
> > javax.jms.JMSException: Peer (vm://localhost#1) disposed.
> > javax.jms.JMSException: Peer (vm://localhost#1) disposed.
> >        at
> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
> >        at
> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1154)
> >        at
> org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56)
> >        at
> org.apache.activemq.ActiveMQConnection.cleanup(ActiveMQConnection.java:1326)
> >        at
> org.apache.activemq.ActiveMQConnection.transportFailed(ActiveMQConnection.java:2027)
> >        at
> org.apache.activemq.ActiveMQConnection$4.run(ActiveMQConnection.java:1663)
> >        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> >        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> >        at java.lang.Thread.run(Thread.java:595)
> > Caused by: org.apache.activemq.transport.TransportDisposedIOException:
> > Peer (vm://localhost#1) disposed.
> >        at
> org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:87)
> >        at
> org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
> >        at
> org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:59)
> >        at
> org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1152)
> >        ... 7 more
> >
> >
> > My broker is running on a linux box with kernel 2.6 (I've read about
> > some similar issues when running on a kernel 2.4).
> > I'm using the following options when starting AMQ:
> > -Xms512m -Xmx1024m -Xmn500m
> >
> > I'm using the default configuration (no persistence).
> > I don't know whether it can help to diagnose the problem, my clients
> > are creating a lot of temporary queues (everything is cleaned up after
> > use), but their lifetime is very short (a few seconds, they are just
> > used to receive a response message).
> > A similar problem occurs on my test client too (maybe it's related to
> > the error on the broker), but not on the server.
> >
> >
> > Any help would be appreciated,
> > Michele
> >
> >
> >
>
>

Re: java.lang.OutOfMemoryError: unable to create new native thread on AMQ 5.0

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
when it happens, do a thread dump to make sure you don't have a thread 
leak (too many threads)

then lower your -Xmx setting, this will make more room in the JVM for 
threads,

Filip

Michele Mazzucco wrote:
> Hi all,
>
> I'm facing the following error while using AMQ 5.0
>
> ERROR efaultMessageListenerContainer - Setup of JMS message listener
> invoker failed - trying to recover
> java.lang.OutOfMemoryError: unable to create new native thread
>         at java.lang.Thread.start0(Native Method)
>         at java.lang.Thread.start(Thread.java:574)
>         at org.apache.activemq.thread.DedicatedTaskRunner.<init>(DedicatedTaskRunner.java:42)
>         at org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:74)
>         at org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:92)
>         at org.apache.activemq.ActiveMQMessageConsumer.start(ActiveMQMessageConsumer.java:993)
>         at org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:222)
>         at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
>         at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
>         at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
>         at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createConsumer(AbstractPollingMessageListenerContainer.java:437)
>         at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:216)
>         at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:297)
>         at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
>         at java.lang.Thread.run(Thread.java:595)
> Exception in thread "DefaultMessageListenerContainer-29"
> java.lang.OutOfMemoryError: unable to create new native thread
>         at java.lang.Thread.start0(Native Method)
>         at java.lang.Thread.start(Thread.java:574)
>         at org.apache.activemq.transport.TransportThreadSupport.doStart(TransportThreadSupport.java:43)ERROR
> Service                        - Async error occurred:
> java.lang.OutOfMemoryError: unable to create new native thread
> java.lang.OutOfMemoryError: unable to create new native thread
>         at java.lang.Thread.start0(Native Method)
>         at java.lang.Thread.start(Thread.java:574)
>         at org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
>         at org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>         at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
>         at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
>         at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
>         at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
>         at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
>         at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
>         at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
>         at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
>         at java.lang.Thread.run(Thread.java:595)
>
>         at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:368)
>         at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:48)
>         at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>         at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>         at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:63)
>         at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>         at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:56)
>         at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:256)
>         at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:220)
>         at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:168)
>         at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:188)
>         at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:209)
>         at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:197)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:701)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:683)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:835)
>         at java.lang.Thread.run(Thread.java:595)
> Exception in thread "ActiveMQ Transport Server: tcp://localhost:61616"
> java.lang.OutOfMemoryError: unable to create new native thread
>         at java.lang.Thread.start0(Native Method)
>         at java.lang.Thread.start(Thread.java:574)
>         at org.apache.activemq.broker.TransportConnector$1.onAccept(TransportConnector.java:160)
>         at org.apache.activemq.transport.tcp.TcpTransportServer.run(TcpTransportServer.java:213)
>         at java.lang.Thread.run(Thread.java:595)
> ERROR Service                        - Async error occurred:
> java.lang.OutOfMemoryError: unable to create new native thread
> java.lang.OutOfMemoryError: unable to create new native thread
>         at java.lang.Thread.start0(Native Method)
>         at java.lang.Thread.start(Thread.java:574)
>         at org.apache.activemq.broker.TransportConnection.processShutdown(TransportConnection.java:326)
>         at org.apache.activemq.command.ShutdownInfo.visit(ShutdownInfo.java:35)
>         at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
>         at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
>         at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
>         at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
>         at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
>         at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
>         at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
>         at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
>         at java.lang.Thread.run(Thread.java:595)
> INFO  BrokerService                  - ActiveMQ Message Broker
> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) is shutting
> down
> INFO  NetworkConnector               - Network Connector
> org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent@17c96a9
> Stopped
> INFO  TransportConnector             - Connector openwire Stopped
> INFO  TransportConnector             - Connector vm://localhost Stopped
> WARN  ActiveMQConnection             - Async exception with no
> exception listener:
> org.apache.activemq.transport.TransportDisposedIOException: Peer
> (vm://localhost#1) disposed.
> org.apache.activemq.transport.TransportDisposedIOException: Peer
> (vm://localhost#1) disposed.
>         at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:200)
>         at org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
>         at org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)
> INFO  BrokerService                  - ActiveMQ JMS Message Broker
> (localhost, ID:giga06.ncl.ac.uk-41771-1209660890412-0:0) stopped
> INFO  AdvisoryConsumer               - Failed to send remove command:
> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
> javax.jms.JMSException: Peer (vm://localhost#1) disposed.
>         at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>         at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1154)
>         at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56)
>         at org.apache.activemq.ActiveMQConnection.cleanup(ActiveMQConnection.java:1326)
>         at org.apache.activemq.ActiveMQConnection.transportFailed(ActiveMQConnection.java:2027)
>         at org.apache.activemq.ActiveMQConnection$4.run(ActiveMQConnection.java:1663)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: org.apache.activemq.transport.TransportDisposedIOException:
> Peer (vm://localhost#1) disposed.
>         at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:87)
>         at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
>         at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:59)
>         at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1152)
>         ... 7 more
>
>
> My broker is running on a linux box with kernel 2.6 (I've read about
> some similar issues when running on a kernel 2.4).
> I'm using the following options when starting AMQ:
> -Xms512m -Xmx1024m -Xmn500m
>
> I'm using the default configuration (no persistence).
> I don't know whether it can help to diagnose the problem, my clients
> are creating a lot of temporary queues (everything is cleaned up after
> use), but their lifetime is very short (a few seconds, they are just
> used to receive a response message).
> A similar problem occurs on my test client too (maybe it's related to
> the error on the broker), but not on the server.
>
>
> Any help would be appreciated,
> Michele
>
>