嵌入式Neo4j数据库在启动时抛出permgen和OutOfMemoryError
我使用的是Spring数据Neo4j 3.2.0和Neo4j 2.1.2 我使用Gradle作为构建工具,并使用Gradle tomcat插件启动正在开发的应用程序。几天来,这一切都很顺利 现在,在过去的一天中,我开始在启动应用程序时出现内存错误。有时,在运行查询之前不会发生错误,但偶尔在启动时会出现内存错误嵌入式Neo4j数据库在启动时抛出permgen和OutOfMemoryError,neo4j,spring-data-neo4j,Neo4j,Spring Data Neo4j,我使用的是Spring数据Neo4j 3.2.0和Neo4j 2.1.2 我使用Gradle作为构建工具,并使用Gradle tomcat插件启动正在开发的应用程序。几天来,这一切都很顺利 现在,在过去的一天中,我开始在启动应用程序时出现内存错误。有时,在运行查询之前不会发生错误,但偶尔在启动时会出现内存错误 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1102557897-37"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1102557897-36"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "HashSessionScavenger-0"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1102557897-38"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1102557897-39"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1102557897-40"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "RMI RenewClean-[10.30.65.86:51134]"
如何启动嵌入式服务器:
public EmbeddedGraphDatabase createEmbeddedDatabase(String storeDir) {
return (EmbeddedGraphDatabase) new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( storeDir )
.setConfig(GraphDatabaseSettings.allow_store_upgrade, "true")
.setConfig(ShellSettings.remote_shell_enabled, "true")
.newGraphDatabase();
Gradle正在使用标准配置启动,该配置在运行后如下所示:
java -Xmx512m -classpath /Users/rwalls/Development/gradle-1.12/lib/gradle-launcher-1.12.jar org.gradle.launcher.GradleMain tomcatRunWar
存储文件大小:
{
"description": "Information about the sizes of the different parts of the Neo4j graph store",
"name": "org.neo4j:instance=kernel#0,name=Store file sizes",
"attributes": [
{
"description": "The total disk space used by this Neo4j instance, in bytes.",
"name": "TotalStoreSize",
"value": 291941310,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used by the current Neo4j logical log, in bytes.",
"name": "LogicalLogSize",
"value": 184,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used to store array properties, in bytes.",
"name": "ArrayStoreSize",
"value": 128,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used to store nodes, in bytes.",
"name": "NodeStoreSize",
"value": 4341060,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used to store properties (excluding string values and array values), in bytes.",
"name": "PropertyStoreSize",
"value": 16972278,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used to store relationships, in bytes.",
"name": "RelationshipStoreSize",
"value": 39276426,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "The amount of disk space used to store string properties, in bytes.",
"name": "StringStoreSize",
"value": 1476352,
"isReadable": "true",
"type": "long",
"isWriteable": "false ",
"isIs": "false "
}
],
"url": "org.neo4j/instance%3Dkernel%230%2Cname%3DStore+file+sizes"
}
服务器配置(似乎依赖于启动):
我意识到我可以在分配更多内存的情况下启动java。。。但尝试了许多不同的选择,仍然有错误
想法
我的下一步是在标准tomcat实例(而不是gradle)中运行该应用程序,看看这是否会有所不同
编辑
堆栈跟踪:
Caused by: java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.gradle.internal.classloader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at org.gradle.internal.classloader.CachingClassLoader.loadClass(CachingClassLoader.java:41)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at org.gradle.internal.classloader.FilteringClassLoader.loadClass(FilteringClassLoader.java:80)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at org.gradle.internal.classloader.CachingClassLoader.loadClass(CachingClassLoader.java:41)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.tools.ant.AntClassLoader.findBaseClass(AntClassLoader.java:1385)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1080)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at ch.qos.logback.classic.spi.PackagingDataCalculator.loadClass(PackagingDataCalculator.java:202)
at ch.qos.logback.classic.spi.PackagingDataCalculator.bestEffortLoadClass(PackagingDataCalculator.java:221)
at ch.qos.logback.classic.spi.PackagingDataCalculator.computeBySTEP(PackagingDataCalculator.java:136)
at ch.qos.logback.classic.spi.PackagingDataCalculator.populateUncommonFrames(PackagingDataCalculator.java:111)
at ch.qos.logback.classic.spi.PackagingDataCalculator.populateFrames(PackagingDataCalculator.java:103)
at ch.qos.logback.classic.spi.PackagingDataCalculator.calculate(PackagingDataCalculator.java:55)
messages.log的粘贴箱:
线程转储的粘贴库:将此行添加到
gradle.properties
org.gradle.jvmargs=-XX:+UseConcMarkSweepGC -Xmx2048m -Xms512m -server -XX:MaxPermSize=512M
它似乎已经解决了这个问题
我之前的尝试失败,因为我正在更新
GRADLE\u OPTS
,这显然不会将内存更改传递给生成的tomcat实例。您有完整的堆栈跟踪可用吗?您还可以共享neo4j日志文件graph.db/messages.log吗?当这些错误发生时,也许可以使用jstack(其中还包括堆信息)创建一个threaddump。@MichaelHunger我用您想要的信息更新了我的答案。谢谢
org.gradle.jvmargs=-XX:+UseConcMarkSweepGC -Xmx2048m -Xms512m -server -XX:MaxPermSize=512M