Hi,

thanks for the answer.

If create a spring bean wich is starting the kafka consumer and this bean has 
an „destroy“ function. You can see it here: 
https://github.com/marcelalburg/spring-integration-kafka-memory-leak/blob/master/src/main/java/org/example/kafkamemoryleak/listener/KafkaConsumerStarter.java#L30
 
<https://github.com/marcelalburg/spring-integration-kafka-memory-leak/blob/master/src/main/java/org/example/kafkamemoryleak/listener/KafkaConsumerStarter.java#L30>

you write that i ‚ve to shutdown the consumer. I’ve an ConsumerContext and i 
call „destroy“ directly. but the error occurs again (in this example above - 
there lines are commented out - but i try this too)

But in the end, i get this error

—
SCHWERWIEGEND: The web application [/spring-integration-kafka-memory-leak] 
created a ThreadLocal with key of type [scala.util.DynamicVariable$$anon$1] 
(value [scala.util.DynamicVariable$$anon$1@526effe5]) and a value of type 
[scala.Some] (value [Some([1.91] failure: end of input

{"jmx_port":-1,"timestamp":"1420541126553","host":"127.0.0.1","version":1,"port":9092}
                                                                                
          ^)]) but failed to remove it when the web application was stopped. 
Threads are going to be renewed over time to try and avoid a probable memory 
leak.
Jan 06, 2015 11:55:58 AM org.apache.catalina.loader.WebappClassLoader 
checkThreadLocalMapForLeaks
SCHWERWIEGEND: The web application [/spring-integration-kafka-memory-leak] 
created a ThreadLocal with key of type [scala.util.DynamicVariable$$anon$1] 
(value [scala.util.DynamicVariable$$anon$1@202d458a]) and a value of type 
[scala.None$] (value [None]) but failed to remove it when the web application 
was stopped. Threads are going to be renewed over time to try and avoid a 
probable memory leak.
Jan 06, 2015 11:55:58 AM org.apache.coyote.AbstractProtocol stop
INFORMATION: Stopping ProtocolHandler ["http-nio-8080"]

Exception: java.lang.IllegalStateException thrown from the 
UncaughtExceptionHandler in thread 
"kafkaTaskExecutor-1-SendThread(127.0.0.1:2181)"
Exception in thread 
"default_MacBook.local-1420541738588-56bc7077_watcher_executor" 
java.lang.IllegalStateException: Can't overwrite cause with 
java.lang.IllegalStateException: Illegal access: this web application instance 
has been stopped already.  Could not load 
kafka.consumer.ZookeeperConsumerConnector$ZKRebalancerListener$$anon$1$$anonfun$run$4.
  The eventual following stack trace is caused by an error thrown for debugging 
purposes as well as to attempt to terminate the thread which caused the illegal 
access, and has no functional impact.
    at java.lang.Throwable.initCause(Throwable.java:457)
    at 
org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1331)
    at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1212)
    at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1173)
    at 
kafka.consumer.ZookeeperConsumerConnector$ZKRebalancerListener$$anon$1.run(ZookeeperConsumerConnector.scala:360)
Caused by: java.lang.ClassNotFoundException
    at 
org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1330)
    ... 3 more
---


Thanks

> Am 07.01.2015 um 00:06 schrieb Bhavesh Mistry <mistry.p.bhav...@gmail.com>:
> 
> Hi Marcel,
> 
> Memory leaks will happen when there are background threads started by webapp 
> and not shutdown (usually lib like Code hale has shutdown hook, but web app 
> you do get to execute shutdown hook so you get memory leaks or class not 
> found).  I have faced this so you need to either use web context listener and 
> close all threads.
> 
> With Old Producer I have faced this issue. I had to explicitly called 
> Metrics.defaultRegistry().shutdown();  for shutdown because producer.close() 
> does not shutdown metics threads. Similar issue if you are consuming consumer 
> side.  Also, you have to call consumer.shutdown() as well. 
> 
> I hope this help ! 
> 
> Thanks,
> 
> Bhavesh 
> 
> 
> On Tue, Jan 6, 2015 at 1:53 PM, Marcel Alburg <m.alb...@weeaar.com 
> <mailto:m.alb...@weeaar.com>> wrote:
> Hello,
> 
> i try to use spring-integration-kafka and after stopping the Tomcat i get
> an "possible memory leak" from the class loader.
> 
> I talked with the people of spring-integration-kafka and you can see this
> talk with a lot of debug messages and an reproduceable project under:
> 
> https://github.com/spring-projects/spring-integration-kafka/issues/10 
> <https://github.com/spring-projects/spring-integration-kafka/issues/10>
> 
> Thanks in advance
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to