java.lang.OutOfMemoryError

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • The RedisMessageListenerContainer uses the SimpleAsyncTaskExecutor, the SimpleAsyncTaskExecutor creates a new, short lived, thread for every message. This causes out of memory errors on our production environment. The spring-data-redis version is 1.3.6-RELEASE, however the latest version (1.7.1) still uses the SimpleAsyncTaskExecutor. The report is below: After about 3 or 4 days of usage (300 concurrent users) our application stopped responding, and the log shows an "java.lang.OutOfMemoryError: unable to create new native thread" error. The default implementation of the RedisMessageListenerContainer uses a SimpleAsyncTaskExecutor that creates a thread on every call to dispatchMessage. This somehow repletes the available threads. The JDK version is 1.7.0_79-b15, 64-Bit. See also: https://plumbr.eu/outofmemoryerror/unable-to-create-new-native-thread The solution is quite simple, make use of one of the java.util.concurrent.Executors to dispatch the message. The stack is: {code} 2016-04-01 08:46:47,507 [redisMessageListenerContainer-1] ERROR org.springframework.data.redis.listener.RedisMessageListenerContainer - SubscriptionTask aborted with exception: java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at org.springframework.core.task.SimpleAsyncTaskExecutor.doExecute(SimpleAsyncTaskExecutor.java:192) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:166) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:147) at org.springframework.data.redis.listener.RedisMessageListenerContainer.dispatchMessage(RedisMessageListenerContainer.java:948) at org.springframework.data.redis.listener.RedisMessageListenerContainer.access$1400(RedisMessageListenerContainer.java:61) at org.springframework.data.redis.listener.RedisMessageListenerContainer$DispatchMessageListener.onMessage(RedisMessageListenerContainer.java:939) at org.springframework.data.redis.connection.jedis.JedisMessageListener.onPMessage(JedisMessageListener.java:43) at redis.clients.jedis.BinaryJedisPubSub.process(BinaryJedisPubSub.java:102) at redis.clients.jedis.BinaryJedisPubSub.proceedWithPatterns(BinaryJedisPubSub.java:69) at redis.clients.jedis.BinaryJedis.psubscribe(BinaryJedis.java:3152) at org.springframework.data.redis.connection.jedis.JedisConnection.pSubscribe(JedisConnection.java:2681) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.eventuallyPerformSubscription(RedisMessageListenerContainer.java:763) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.run(RedisMessageListenerContainer.java:730) at java.lang.Thread.run(Thread.java:745) {code}
    via by Roland,
  • The RedisMessageListenerContainer uses the SimpleAsyncTaskExecutor, the SimpleAsyncTaskExecutor creates a new, short lived, thread for every message. This causes out of memory errors on our production environment. The spring-data-redis version is 1.3.6-RELEASE, however the latest version (1.7.1) still uses the SimpleAsyncTaskExecutor. The report is below: After about 3 or 4 days of usage (300 concurrent users) our application stopped responding, and the log shows an "java.lang.OutOfMemoryError: unable to create new native thread" error. The default implementation of the RedisMessageListenerContainer uses a SimpleAsyncTaskExecutor that creates a thread on every call to dispatchMessage. This somehow repletes the available threads. The JDK version is 1.7.0_79-b15, 64-Bit. See also: https://plumbr.eu/outofmemoryerror/unable-to-create-new-native-thread The solution is quite simple, make use of one of the java.util.concurrent.Executors to dispatch the message. The stack is: {code} 2016-04-01 08:46:47,507 [redisMessageListenerContainer-1] ERROR org.springframework.data.redis.listener.RedisMessageListenerContainer - SubscriptionTask aborted with exception: java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at org.springframework.core.task.SimpleAsyncTaskExecutor.doExecute(SimpleAsyncTaskExecutor.java:192) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:166) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:147) at org.springframework.data.redis.listener.RedisMessageListenerContainer.dispatchMessage(RedisMessageListenerContainer.java:948) at org.springframework.data.redis.listener.RedisMessageListenerContainer.access$1400(RedisMessageListenerContainer.java:61) at org.springframework.data.redis.listener.RedisMessageListenerContainer$DispatchMessageListener.onMessage(RedisMessageListenerContainer.java:939) at org.springframework.data.redis.connection.jedis.JedisMessageListener.onPMessage(JedisMessageListener.java:43) at redis.clients.jedis.BinaryJedisPubSub.process(BinaryJedisPubSub.java:102) at redis.clients.jedis.BinaryJedisPubSub.proceedWithPatterns(BinaryJedisPubSub.java:69) at redis.clients.jedis.BinaryJedis.psubscribe(BinaryJedis.java:3152) at org.springframework.data.redis.connection.jedis.JedisConnection.pSubscribe(JedisConnection.java:2681) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.eventuallyPerformSubscription(RedisMessageListenerContainer.java:763) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.run(RedisMessageListenerContainer.java:730) at java.lang.Thread.run(Thread.java:745) {code}
    via by Roland,
  • GitHub comment 96#162611775
    via GitHub by Metal-Mighty
    ,
  • OutOfMemoryError even though enough free memory
    via by Unknown author,
    • java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at org.springframework.core.task.SimpleAsyncTaskExecutor.doExecute(SimpleAsyncTaskExecutor.java:192) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:166) at org.springframework.core.task.SimpleAsyncTaskExecutor.execute(SimpleAsyncTaskExecutor.java:147) at org.springframework.data.redis.listener.RedisMessageListenerContainer.dispatchMessage(RedisMessageListenerContainer.java:948) at org.springframework.data.redis.listener.RedisMessageListenerContainer.access$1400(RedisMessageListenerContainer.java:61) at org.springframework.data.redis.listener.RedisMessageListenerContainer$DispatchMessageListener.onMessage(RedisMessageListenerContainer.java:939) at org.springframework.data.redis.connection.jedis.JedisMessageListener.onPMessage(JedisMessageListener.java:43) at redis.clients.jedis.BinaryJedisPubSub.process(BinaryJedisPubSub.java:102) at redis.clients.jedis.BinaryJedisPubSub.proceedWithPatterns(BinaryJedisPubSub.java:69) at redis.clients.jedis.BinaryJedis.psubscribe(BinaryJedis.java:3152) at org.springframework.data.redis.connection.jedis.JedisConnection.pSubscribe(JedisConnection.java:2681) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.eventuallyPerformSubscription(RedisMessageListenerContainer.java:763) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.run(RedisMessageListenerContainer.java:730) at java.lang.Thread.run(Thread.java:745)

    Users with the same issue

    nasimk
    1 times, last one,
    poroszd
    530 times, last one,
    Unknown visitor1 times, last one,
    Reich
    4 times, last one,
    Unknown visitor1 times, last one,
    50 more bugmates