ava.lang.OutOfMemoryError: Java heap space

Spring JIRA | Balaji | 1 year ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    I am using following code to get data from redis nodes *RedisTemplate<String, ?> redisTemplate1 = (RedisTemplate<String, ?>) ctx.getBean("redisTemplate1"); RedisTemplate<String, ?> redisTemplate2 = (RedisTemplate<String, ?>) ctx.getBean("redisTemplate2"); List<MediaTrackBO> timeZones = new ArrayList<MediaTrackBO>(); try{ for (Object timezone : redisTemplate2.opsForHash().values(RivetUtil.OBJECT_KEY) ){ timeZones.add((MediaTrackBO) timezone); } if(timeZones.size() <=0){ timeZones=getObjects1(); } }catch(Exception e){ for (Object timezone : redisTemplate1.opsForHash().values(RivetUtil.OBJECT_KEY) ){ timeZones.add((MediaTrackBO) timezone); } }* some times i am getting following exception j{color:red}ava.lang.OutOfMemoryError: Java heap space at redis.clients.jedis.Protocol.processBulkReply(Protocol.java:168) at redis.clients.jedis.Protocol.process(Protocol.java:145) at redis.clients.jedis.Protocol.processMultiBulkReply(Protocol.java:196) at redis.clients.jedis.Protocol.process(Protocol.java:147) at redis.clients.jedis.Protocol.read(Protocol.java:205) at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297) at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:233) at redis.clients.jedis.BinaryJedis.hvals(BinaryJedis.java:917) at org.springframework.data.redis.connection.jedis.JedisConnection.hVals(JedisConnection.java:2909) at org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:197) at org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:194) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:191) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86) at org.springframework.data.redis.core.DefaultHashOperations.values(DefaultHashOperations.java:194) at com.rivetnewsradio.cd.domain.redis.dao.MainPlaylistRepository.getObjects2(MainPlaylistRepository.java:85) at com.rivetnewsradio.cd.service.PlayListServiceImpl.findMainPlaylistFromRedis(PlayListServiceImpl.java:139) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy42.findMainPlaylistFromRedis(Unknown Source) at com.rivetnewsradio.cd.web.PlayListController.getMainPlayList(PlayListController.java:169) at sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43){color} So please let me know better way to fix it, as soon as possible because of it is in production.

    Spring JIRA | 1 year ago | Balaji
    ava.lang.OutOfMemoryError: Java heap space
  2. 0

    I am using following code to get data from redis nodes *RedisTemplate<String, ?> redisTemplate1 = (RedisTemplate<String, ?>) ctx.getBean("redisTemplate1"); RedisTemplate<String, ?> redisTemplate2 = (RedisTemplate<String, ?>) ctx.getBean("redisTemplate2"); List<MediaTrackBO> timeZones = new ArrayList<MediaTrackBO>(); try{ for (Object timezone : redisTemplate2.opsForHash().values(RivetUtil.OBJECT_KEY) ){ timeZones.add((MediaTrackBO) timezone); } if(timeZones.size() <=0){ timeZones=getObjects1(); } }catch(Exception e){ for (Object timezone : redisTemplate1.opsForHash().values(RivetUtil.OBJECT_KEY) ){ timeZones.add((MediaTrackBO) timezone); } }* some times i am getting following exception j{color:red}ava.lang.OutOfMemoryError: Java heap space at redis.clients.jedis.Protocol.processBulkReply(Protocol.java:168) at redis.clients.jedis.Protocol.process(Protocol.java:145) at redis.clients.jedis.Protocol.processMultiBulkReply(Protocol.java:196) at redis.clients.jedis.Protocol.process(Protocol.java:147) at redis.clients.jedis.Protocol.read(Protocol.java:205) at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297) at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:233) at redis.clients.jedis.BinaryJedis.hvals(BinaryJedis.java:917) at org.springframework.data.redis.connection.jedis.JedisConnection.hVals(JedisConnection.java:2909) at org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:197) at org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:194) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:191) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86) at org.springframework.data.redis.core.DefaultHashOperations.values(DefaultHashOperations.java:194) at com.rivetnewsradio.cd.domain.redis.dao.MainPlaylistRepository.getObjects2(MainPlaylistRepository.java:85) at com.rivetnewsradio.cd.service.PlayListServiceImpl.findMainPlaylistFromRedis(PlayListServiceImpl.java:139) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy42.findMainPlaylistFromRedis(Unknown Source) at com.rivetnewsradio.cd.web.PlayListController.getMainPlayList(PlayListController.java:169) at sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43){color} So please let me know better way to fix it, as soon as possible because of it is in production.

    Spring JIRA | 1 year ago | Balaji
    ava.lang.OutOfMemoryError: Java heap space

    Root Cause Analysis

    1. ava.lang.OutOfMemoryError

      Java heap space

      at redis.clients.jedis.Protocol.processBulkReply()
    2. Jedis
      BinaryJedis.hvals
      1. redis.clients.jedis.Protocol.processBulkReply(Protocol.java:168)
      2. redis.clients.jedis.Protocol.process(Protocol.java:145)
      3. redis.clients.jedis.Protocol.processMultiBulkReply(Protocol.java:196)
      4. redis.clients.jedis.Protocol.process(Protocol.java:147)
      5. redis.clients.jedis.Protocol.read(Protocol.java:205)
      6. redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
      7. redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:233)
      8. redis.clients.jedis.BinaryJedis.hvals(BinaryJedis.java:917)
      8 frames
    3. Spring Data Redis
      DefaultHashOperations.values
      1. org.springframework.data.redis.connection.jedis.JedisConnection.hVals(JedisConnection.java:2909)
      2. org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:197)
      3. org.springframework.data.redis.core.DefaultHashOperations$11.doInRedis(DefaultHashOperations.java:194)
      4. org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:191)
      5. org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
      6. org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86)
      7. org.springframework.data.redis.core.DefaultHashOperations.values(DefaultHashOperations.java:194)
      7 frames
    4. com.rivetnewsradio.cd
      PlayListServiceImpl.findMainPlaylistFromRedis
      1. com.rivetnewsradio.cd.domain.redis.dao.MainPlaylistRepository.getObjects2(MainPlaylistRepository.java:85)
      2. com.rivetnewsradio.cd.service.PlayListServiceImpl.findMainPlaylistFromRedis(PlayListServiceImpl.java:139)
      2 frames
    5. Java RT
      Method.invoke
      1. sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
      2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3. java.lang.reflect.Method.invoke(Method.java:606)
      3 frames
    6. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      3 frames
    7. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
      3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      3 frames
    8. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      2 frames
    9. com.sun.proxy
      $Proxy42.findMainPlaylistFromRedis
      1. com.sun.proxy.$Proxy42.findMainPlaylistFromRedis(Unknown Source)
      1 frame
    10. com.rivetnewsradio.cd
      PlayListController.getMainPlayList
      1. com.rivetnewsradio.cd.web.PlayListController.getMainPlayList(PlayListController.java:169)
      1 frame
    11. Java RT
      GeneratedMethodAccessor94.invoke
      1. sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source)
      1 frame