2017-04-14 157 views
2

我最近部署了一個計劃每天運行的Spring Boot應用程序,以解析來自Cassandra羣集的新數據。大約20個小時的工作之後(約300萬的讀/寫訪問卡桑德拉)出現和一些內存的問題在每次迭代(唯一的例外是環內抓)我有這樣的錯誤:Spring Boot應用程序緩存內存泄漏

java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.createAccessorClass(ClassGeneratingPropertyAccessorFactory.java:170) 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.potentiallyCreateAndRegisterPersistentPropertyAccessorClass(ClassGeneratingPropertyAccessorFactory.java:154) 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.getPropertyAccessor(ClassGeneratingPropertyAccessorFactory.java:80) 
    at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:425) 
    at org.springframework.data.cassandra.convert.MappingCassandraConverter.getConvertingAccessor(MappingCassandraConverter.java:611) 
    at org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:172) 
    at org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:149) 
    at com.myapp.utils.CassandraIterable$1.next(CassandraIterable.java:35) 
    at com.myapp.service.packer.PositionParsingService.parse(PositionParsingService.java:60) 
    at com.myapp.service.packer.PositionLoadService.update(PositionLoadService.java:202) 
    at com.myapp.service.packer.PositionLoadService.updateVehicle(PositionLoadService.java:129) 
    at com.myapp.service.packer.PositionLoadService.updateAllVehicles(PositionLoadService.java:99) 
    at com.myapp.service.packer.PositionLoadService.updateAllVehicles(PositionLoadService.java:84) 
    at com.myapp.service.packer.PositionLoadService$$FastClassBySpringCGLIB$$2605bc6c.invoke(<generated>) 
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) 
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory$Evil.defineClass(ClassGeneratingPropertyAccessorFactory.java:1480) 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory$PropertyAccessorClassGenerator.generateCustomAccessorClass(ClassGeneratingPropertyAccessorFactory.java:282) 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.createAccessorClass(ClassGeneratingPropertyAccessorFactory.java:168) 
    ... 21 common frames omitted 
Caused by: java.lang.reflect.InvocationTargetException: null 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory$Evil.defineClass(ClassGeneratingPropertyAccessorFactory.java:1476) 
    ... 23 common frames omitted 
Caused by: java.lang.OutOfMemoryError: Compressed class space 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) 
    ... 28 common frames omitted 

通過分析內存轉儲生產發生問題後,我有這個報告:

Retained Detail

從Java任務控制,我運行一個垃圾收集後,我得到:

Memory usage

我不認爲我的代碼是直接負責泄漏,即使可能有東西沒有發佈時,它應該或可能有一些配置問題,我忽略了。

我試圖從java JDK SE 8u60升級到8u121並將Spring引導升級到版本1.5.2.RELEASE。這裏是完整的依賴列表:

com.myapp:jar:0.0.1-SNAPSHOT 
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.2.RELEASE:compile 
| +- org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile 
| | +- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.2.RELEASE:compile 
| | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile 
| | | | +- ch.qos.logback:logback-core:jar:1.1.11:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) 
| | | +- org.slf4j:jcl-over-slf4j:jar:1.7.24:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) 
| | | +- org.slf4j:jul-to-slf4j:jar:1.7.24:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) 
| | | \- org.slf4j:log4j-over-slf4j:jar:1.7.24:compile 
| | |  \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) 
| | +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile 
| | \- org.yaml:snakeyaml:jar:1.17:runtime 
| +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.2.RELEASE:compile 
| | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework:spring-aop:jar:4.3.7.RELEASE:compile 
| | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | \- org.aspectj:aspectjweaver:jar:1.8.9:compile 
| +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.2.RELEASE:compile 
| | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile 
| | | \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile 
| | \- org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile 
| |  +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| |  +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| |  \- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| +- org.hibernate:hibernate-core:jar:5.0.12.Final:compile 
| | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile 
| | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile 
| | +- org.javassist:javassist:jar:3.21.0-GA:compile (version managed from 3.18.1-GA) 
| | +- antlr:antlr:jar:2.7.7:compile 
| | +- org.jboss:jandex:jar:2.0.0.Final:compile 
| | +- dom4j:dom4j:jar:1.6.1:compile 
| | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile 
| |  \- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) 
| +- org.hibernate:hibernate-entitymanager:jar:5.0.12.Final:compile 
| | +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) 
| | +- (org.hibernate:hibernate-core:jar:5.0.12.Final:compile - omitted for duplicate) 
| | +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate) 
| | +- (org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile - omitted for duplicate) 
| | +- (org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile - omitted for duplicate) 
| | \- (org.javassist:javassist:jar:3.21.0-GA:compile - version managed from 3.18.1-GA; omitted for duplicate) 
| +- javax.transaction:javax.transaction-api:jar:1.2:compile 
| +- org.springframework.data:spring-data-jpa:jar:1.11.1.RELEASE:compile 
| | +- org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile 
| | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) 
| | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:runtime - omitted for duplicate) 
| | +- org.springframework:spring-orm:jar:4.3.7.RELEASE:compile 
| | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework:spring-context:jar:4.3.7.RELEASE:compile 
| | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework:spring-beans:jar:4.3.7.RELEASE:compile 
| | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- org.slf4j:slf4j-api:jar:1.7.24:compile 
| | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:compile - scope updated from runtime; omitted for duplicate) 
| \- org.springframework:spring-aspects:jar:4.3.7.RELEASE:compile 
|  \- (org.aspectj:aspectjweaver:jar:1.8.9:compile - omitted for duplicate) 
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.2.RELEASE:compile 
| +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.2.RELEASE:compile 
| | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile 
| | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile 
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile 
| |  \- (org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile - omitted for duplicate) 
| +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile 
| | +- javax.validation:validation-api:jar:1.1.0.Final:compile 
| | +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) 
| | \- com.fasterxml:classmate:jar:1.3.3:compile (version managed from 1.3.1) 
| +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile 
| | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - omitted for duplicate) 
| | \- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) 
| +- org.springframework:spring-web:jar:4.3.7.RELEASE:compile 
| | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| \- org.springframework:spring-webmvc:jar:4.3.7.RELEASE:compile 
|  +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  +- org.springframework:spring-expression:jar:4.3.7.RELEASE:compile 
|  | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  \- (org.springframework:spring-web:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
+- org.springframework.boot:spring-boot-starter-data-cassandra:jar:1.5.2.RELEASE:compile 
| +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
| +- org.springframework:spring-tx:jar:4.3.7.RELEASE:compile 
| | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| \- org.springframework.data:spring-data-cassandra:jar:1.5.1.RELEASE:compile 
|  +- org.springframework.data:spring-cql:jar:1.5.1.RELEASE:compile 
|  | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  | +- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  | +- (org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile - omitted for duplicate) 
|  | +- (com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile - version managed from 3.1.3; omitted for duplicate) 
|  | +- (com.google.guava:guava:jar:19.0:compile - omitted for conflict with 16.0.1) 
|  | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) 
|  | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:runtime - omitted for duplicate) 
|  +- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile - omitted for duplicate) 
|  +- (com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile - version managed from 3.1.3; omitted for duplicate) 
|  +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) 
|  \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:compile - scope updated from runtime; omitted for duplicate) 
+- org.springframework.boot:spring-boot-devtools:jar:1.5.2.RELEASE:compile 
| +- org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile 
| | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| | \- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) 
| \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:compile 
|  \- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile - omitted for duplicate) 
+- com.datastax.cassandra:cassandra-driver-mapping:jar:3.1.4:compile 
| \- com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile 
|  +- io.netty:netty-handler:jar:4.0.37.Final:compile 
|  | +- io.netty:netty-buffer:jar:4.0.37.Final:compile 
|  | | \- io.netty:netty-common:jar:4.0.37.Final:compile 
|  | +- io.netty:netty-transport:jar:4.0.37.Final:compile 
|  | | \- (io.netty:netty-buffer:jar:4.0.37.Final:compile - omitted for duplicate) 
|  | \- io.netty:netty-codec:jar:4.0.37.Final:compile 
|  |  \- (io.netty:netty-transport:jar:4.0.37.Final:compile - omitted for duplicate) 
|  +- com.google.guava:guava:jar:16.0.1:compile 
|  +- io.dropwizard.metrics:metrics-core:jar:3.1.3:compile (version managed from 3.1.2) 
|  | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) 
|  +- com.github.jnr:jnr-ffi:jar:2.0.7:compile 
|  | +- com.github.jnr:jffi:jar:1.2.10:compile 
|  | +- com.github.jnr:jffi:jar:native:1.2.10:runtime 
|  | +- org.ow2.asm:asm:jar:5.0.3:compile 
|  | +- org.ow2.asm:asm-commons:jar:5.0.3:compile 
|  | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) 
|  | +- org.ow2.asm:asm-analysis:jar:5.0.3:compile 
|  | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) 
|  | +- org.ow2.asm:asm-tree:jar:5.0.3:compile 
|  | | \- (org.ow2.asm:asm:jar:5.0.3:compile - omitted for duplicate) 
|  | +- org.ow2.asm:asm-util:jar:5.0.3:compile 
|  | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) 
|  | \- com.github.jnr:jnr-x86asm:jar:1.0.2:compile 
|  \- com.github.jnr:jnr-posix:jar:3.0.27:compile 
|  +- (com.github.jnr:jnr-ffi:jar:2.0.7:compile - omitted for duplicate) 
|  \- com.github.jnr:jnr-constants:jar:0.9.0:compile 
+- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.7:compile 
| +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile 
| +- com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile 
| \- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - omitted for duplicate) 
+- com.oracle.jdbc:ojdbc7:jar:12.1.0.2:compile 
| +- com.oracle.jdbc:xdb6:jar:12.1.0.2:compile 
| +- com.oracle.jdbc:orai18n:jar:12.1.0.2:compile 
| +- com.oracle.jdbc:xmlparserv2:jar:12.1.0.2:compile 
| +- com.oracle.jdbc:oraclepki:jar:12.1.0.2:compile 
| +- com.oracle.jdbc:osdt_cert:jar:12.1.0.2:compile 
| \- com.oracle.jdbc:osdt_core:jar:12.1.0.2:compile 
+- com.mycompany:Pandora-json:jar:2.1.0-SNAPSHOT:compile 
| +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.5.4; omitted for duplicate) 
| +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) 
| +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.8.7:compile (version managed from 2.5.4) 
| | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.5.4; omitted for duplicate) 
| | +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) 
| | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) 
| | \- (joda-time:joda-time:jar:2.9.7:compile - version managed from 2.7; omitted for duplicate) 
| \- com.fasterxml.jackson.datatype:jackson-datatype-guava:jar:2.8.7:compile (version managed from 2.4.0) 
|  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) 
|  +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) 
|  \- (com.google.guava:guava:jar:16.0:compile - omitted for conflict with 16.0.1) 
+- javax.inject:javax.inject:jar:1:compile 
+- joda-time:joda-time:jar:2.9.7:compile 
+- org.projectlombok:lombok:jar:1.16.14:compile 
+- org.springframework.boot:spring-boot-starter-test:jar:1.5.2.RELEASE:test 
| +- org.springframework.boot:spring-boot-test:jar:1.5.2.RELEASE:test 
| | \- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:test - omitted for duplicate) 
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.2.RELEASE:test 
| | +- (org.springframework.boot:spring-boot-test:jar:1.5.2.RELEASE:test - omitted for duplicate) 
| | \- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:test - omitted for duplicate) 
| +- com.jayway.jsonpath:json-path:jar:2.2.0:test 
| | +- net.minidev:json-smart:jar:2.2.1:test 
| | | \- net.minidev:accessors-smart:jar:1.1:test 
| | |  \- (org.ow2.asm:asm:jar:5.0.3:test - omitted for duplicate) 
| | \- (org.slf4j:slf4j-api:jar:1.7.24:test - version managed from 1.7.16; omitted for duplicate) 
| +- junit:junit:jar:4.12:test 
| | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) 
| +- (org.assertj:assertj-core:jar:2.6.0:test - omitted for conflict with 3.6.2) 
| +- org.mockito:mockito-core:jar:1.10.19:test 
| | +- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) 
| | \- org.objenesis:objenesis:jar:2.1:test 
| +- org.hamcrest:hamcrest-core:jar:1.3:test 
| +- org.hamcrest:hamcrest-library:jar:1.3:test 
| | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) 
| +- org.skyscreamer:jsonassert:jar:1.4.0:test 
| | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test 
| +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - scope updated from test; omitted for duplicate) 
| \- org.springframework:spring-test:jar:4.3.7.RELEASE:test 
|  \- (org.springframework:spring-core:jar:4.3.7.RELEASE:test - omitted for duplicate) 
+- commons-lang:commons-lang:jar:2.2:compile 
+- org.assertj:assertj-core:jar:3.6.2:compile 
+- org.mockito:mockito-all:jar:1.10.19:test 
+- net.sourceforge.dynamicreports:dynamicreports-core:jar:4.1.1:compile 
| +- net.sf.jasperreports:jasperreports:jar:6.2.2:compile 
| | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile (version managed from 1.9.0) 
| | | \- (commons-collections:commons-collections:jar:3.2.2:compile - omitted for duplicate) 
| | +- commons-collections:commons-collections:jar:3.2.2:compile 
| | +- commons-digester:commons-digester:jar:2.1:compile 
| | | \- (commons-beanutils:commons-beanutils:jar:1.9.3:compile - version managed from 1.8.3; omitted for duplicate) 
| | +- commons-logging:commons-logging:jar:1.1.1:compile 
| | +- com.lowagie:itext:jar:2.1.7.js5:compile 
| | | \- bouncycastle:bcprov-jdk14:jar:138:compile 
| | +- org.jfree:jcommon:jar:1.0.23:compile 
| | +- org.jfree:jfreechart:jar:1.0.19:compile 
| | | \- (org.jfree:jcommon:jar:1.0.23:compile - omitted for duplicate) 
| | +- org.eclipse.jdt.core.compiler:ecj:jar:4.3.1:compile 
| | +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - version managed from 2.1.4; omitted for duplicate) 
| | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.1.4; omitted for duplicate) 
| | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.1.4; omitted for duplicate) 
| | \- com.google.zxing:core:jar:2.3.0:compile 
| +- org.apache.commons:commons-lang3:jar:3.1:compile 
| +- net.sf.barcode4j:barcode4j:jar:2.0:compile 
| | +- avalon-framework:avalon-framework-impl:jar:4.2.0:compile 
| | \- xml-apis:xml-apis:jar:1.4.01:compile (version managed from 1.3.04) 
| \- org.apache.xmlgraphics:batik-bridge:jar:1.8:compile 
|  +- org.apache.xmlgraphics:batik-anim:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-dom:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-parser:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-svg-dom:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile 
|  | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-css:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-dom:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-xml:jar:1.8:compile - omitted for duplicate) 
|  | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-ext:jar:1.8:compile 
|  | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-gvt:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) 
|  | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-parser:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-xml:jar:1.8:compile - omitted for duplicate) 
|  | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-script:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-anim:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-svg-dom:jar:1.8:compile 
|  | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-dom:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-parser:jar:1.8:compile - omitted for duplicate) 
|  | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
|  +- org.apache.xmlgraphics:batik-util:jar:1.8:compile 
|  +- org.apache.xmlgraphics:batik-xml:jar:1.8:compile 
|  | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) 
|  +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) 
|  \- xml-apis:xml-apis-ext:jar:1.3.04:compile 
+- org.apache.poi:poi:jar:3.14:compile 
| \- commons-codec:commons-codec:jar:1.10:compile 
\- org.apache.poi:poi-ooxml:jar:3.14:compile 
    +- (org.apache.poi:poi:jar:3.14:compile - omitted for duplicate) 
    +- org.apache.poi:poi-ooxml-schemas:jar:3.14:compile 
    | \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile 
    |  \- stax:stax-api:jar:1.0.1:compile 
    \- com.github.virtuald:curvesapi:jar:1.03:compile 
+1

也許很高興看到'PositionLoadService'類 – Patrick

+0

添加代碼的一些部分。 'com.myapp.utils.CassandraIterable'和'com.myapp.service.packer.PositionParsingService'爲了看看那裏發生了什麼。 – questionare

+0

我在主要描述中的兩個鏈接中添加了代碼 – simo

回答

3

我終於設法解決了這個問題。造成這種情況的原因是我正在爲CassandraIterable的每個實例重新實例化MappingCassandraConverter。

public class CassandraIterable<T> implements Iterable<T> { 

    private final Iterator<Row> iterator; 
    private final Class<T> entityType; 

    private final MappingCassandraConverter converter = new MappingCassandraConverter(); 

    ... 

} 

,而我應該已經創建了一次,它傳遞給了Iterable:沒有垃圾回收

public class CassandraIterable<T> implements Iterable<T> { 


    private final Iterator<Row> iterator; 
    private final Class<T> entityType; 

    private final MappingCassandraConverter converter; 

    public CassandraIterable(Iterator<Row> iterator, Class<T> entityType, MappingCassandraConverter converter) { 

     this.iterator = iterator; 
     this.entityType = entityType; 
     this.converter = converter; 
    } 

    @Override 
    public Iterator<T> iterator() { 
     return 
       new Iterator<T>() { 
        @Override 
        public boolean hasNext() { 
         return 
           iterator.hasNext(); 
        } 

        @Override 
        public T next() { 
         return 
           converter.readRow(entityType, iterator.next()); 
        } 
       }; 
    } 
} 

MappingCassandraConverter(我假定卡桑德拉會議指向它)和訪問到我的班可能是由轉換器指出的。

爲什麼我無法找到泄漏的原因是,有沒有參與泄漏的特定類型:

我期待看到我的類型之一,在內存中,因爲重複千萬次而不是泄漏。之所以沒有發生,是因爲我的代碼中的問題是爲Cassandra實體創建了很多訪問器,即使只生成了一個類類型。爲此參與了泄漏,該班是這樣的:

enter image description here

,他們也沒有那是由總大小排序類型進行分組列表的頂部。