我使用的是Spring Data 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 "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"
}
服务器配置(似乎取决于启动):
{
"description": "The configuration parameters used to configure Neo4j",
"name": "org.neo4j:instance=kernel#0,name=Configuration",
"attributes": [
{
"description": "Configuration attribute",
"name": "store_dir",
"value": "/Users/rwalls/Development/neo4j-community-2.1.2/data/graph.db",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "neostore.nodestore.db.mapped_memory",
"value": "460M",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Enable a remote shell server which shell clients can log in to",
"name": "remote_shell_enabled",
"value": "true",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "ephemeral",
"value": "false",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "neostore.propertystore.db.strings.mapped_memory",
"value": "1408M",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "neostore.propertystore.db.arrays.mapped_memory",
"value": "1596M",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "allow_store_upgrade",
"value": "true",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "neostore.relationshipstore.db.mapped_memory",
"value": "2031M",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
},
{
"description": "Configuration attribute",
"name": "neostore.propertystore.db.mapped_memory",
"value": "1657M",
"isReadable": "true",
"type": "java.lang.String",
"isWriteable": "false ",
"isIs": "false "
}
],
"url": "org.neo4j/instance%3Dkernel%230%2Cname%3DConfiguration"
}
我意识到我可以在分配更多内存的情况下启动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的粘贴:http://pastebin.com/uD8KnpaX threaddump的Pastebin:http://pastebin.com/ipXwH7Vc
答案 0 :(得分:1)
将此行添加到gradle.properties
org.gradle.jvmargs=-XX:+UseConcMarkSweepGC -Xmx2048m -Xms512m -server -XX:MaxPermSize=512M
似乎已经解决了这个问题。
我以前的尝试失败了,因为我正在更新GRADLE_OPTS
,显然没有将内存更改传递给生成的tomcat实例。