title: Neo4j embedded in java out of memory (something wrong with cache)
body: <p>In my research project, I partition my whole graph data into many parts, and store each part in its own graph.db folder
  then, I may load 10 or 15  graph.db into memory at the same time( new Neo4jGraph(/path/to/graph.db) , I use blueprint api ), because I want to traverse on these part of graph which means if I can't find the node I want in this graph.db, I'll try to find it on other graph.db.</p>
  
  <p>It works fine at first, but when it ran for a while, it'll throw these exceptions:</p>
  
  <pre><code> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.atomic.AtomicReferenceArray.&lt;init&gt;(AtomicReferenceArray.java:94)
    at org.neo4j.kernel.impl.cache.GCResistantCache.&lt;init&gt;(GCResistantCache.java:89)
    at org.neo4j.kernel.impl.cache.GCResistantCacheProvider.newRelationshipCache(GCResistantCacheProvider.java:75)
    at org.neo4j.kernel.impl.core.DefaultCaches.relationship(DefaultCaches.java:54)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:458)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:256)
    at org.neo4j.kernel.EmbeddedGraphDatabase.&lt;init&gt;(EmbeddedGraphDatabase.java:106)
    at org.neo4j.kernel.EmbeddedGraphDatabase.&lt;init&gt;(EmbeddedGraphDatabase.java:81)
    at com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph.&lt;init&gt;(Neo4jGraph.java:153)
    at netdb.graph.unit.CacheManager.loadGraphToCache(CacheManager.java:125)
    at netdb.graph.unit.CacheManager.findVertexInCache(CacheManager.java:67)
    at netdb.graph.opts.framework.IndexedGraph.query(IndexedGraph.java:47)
    at netdb.graph.opts.framework.run.OptsExecutor.run(OptsExecutor.java:62)
    at netdb.graph.opts.framework.run.OptsExecutor.main(OptsExecutor.java:129)
  </code></pre>
  
  <p>By the way, here is my jvm setting:</p>
  
  <pre><code>java -jar -Xmx90G -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA
  </code></pre>
  
  <p>and neo4j.propertise:</p>
  
  <pre><code>neostore.nodestore.db.mapped_memory=15G
  neostore.relationshipstore.db.mapped_memory=30G
  neostore.propertystore.db.mapped_memory=50G
  neostore.propertystore.db.strings.mapped_memory=2G
  neostore.propertystore.db.arrays.mapped_memory=2G
  </code></pre>
  
  <p>Does anyone know where should I look into? How can I avoid these error?
  any advice are welcome</p>
  
  <p>Thank you very much!</p>
  
  <p>--------------update for code snippet ----------<br>
  <a href="https://gist.github.com/ArvinH/9b9a4d38ce20758eb5c8" rel="nofollow">my code snippet</a><br>
  maybe take a look at method loadGraphToCache</p>