Hi, I'm running the following code On a 64-bit JVM , JDK 1.7.0, with 4GB RAM, and at a certain point in GetStressTest1() The Exception Re-occurs over and over no matter what the configurations of the JVM at start up are !
Code:
static EmbeddedGraphDatabase gdb ;
static String DB_PATH = "./GDatabase";
static Index<Node> userIndexer;
static Node userNS;
static int NODES_COUNT = 200000;
public static void main(String[] args) {
gdb = new EmbeddedGraphDatabase(DB_PATH);
RegisterShutdownHook(gdb);
Transaction tx = gdb.beginTx();
try{
userIndexer = gdb.index().forNodes("users");
userNS = gdb.createNode();
gdb.getReferenceNode().createRelationshipTo(userNS, RelTypes.USER_NS);
tx.success();
}catch(Exception e){
System.out.println("Error in main Method ! won't perform any tests !");
return;
}finally{
tx.finish();
}
StoreStressTest1(0, NODES_COUNT);
//StoreStressTest2(NODES_COUNT/2, NODES_COUNT);
GetStressTest1();
}
public static String Id2UserName(final int id){
}
private static void CreateIndexInsert(final int id,final String username){
Node usernode = gdb.createNode();
usernode.setProperty("username", username);
userIndexer.add(usernode,""+id, username);
userNS.createRelationshipTo(usernode, RelTypes.USER);
}
private static long GetNode(){
long start,end;
int Id2find = ((int)(Math.random()*NODES_COUNT));
start = System.currentTimeMillis();
Node user2find = userIndexer.get(""+Id2find, Id2UserName(Id2find)).getSingle();
end = System.currentTimeMillis();
return end - start;
}
private static void RegisterShutdownHook(final GraphDatabaseService GraphDB){
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run(){
GraphDB.shutdown();
}
});
}
private static void StoreStressTest1(int first,int last){
long start = 0,end = 0;
Transaction tx = gdb.beginTx();
try{
start = System.currentTimeMillis();
for (int i = first; i < last; i++) {
CreateIndexInsert(i, Id2UserName(i));
}
tx.success();
}catch(Exception e){
System.out.println("Message: " + e.getMessage());
}finally{
tx.finish();
end = System.currentTimeMillis();
System.out.println("(SS1)Insert Time for " + (last - first)+" Nodes: " + (end - start));
}
}
private static void GetStressTest1(){
long accumulator = 0;
Transaction tx = gdb.beginTx();
try{
for (int i = 0; i < NODES_COUNT; i++) {
accumulator+= GetNode();
}
tx.success();
System.out.println("Time for " + NODES_COUNT +" Retrieves is " + accumulator);
}catch(Exception e){
System.out.println("Message: " + e.getMessage());
}finally{
tx.finish();
}
}
Here's the Output Given by the console :
run:
(SS1)Insert Time for 200000 Nodes: 280068
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.apache.lucene.index.SegmentNorms.bytes(SegmentNorms.java:156)
at org.apache.lucene.index.SegmentNorms.bytes(SegmentNorms.java:143)
at org.apache.lucene.index.SegmentReader.norms(SegmentReader.java:599)
at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:107)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:577)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)
at org.neo4j.index.impl.lucene.Hits.getMoreDocs(Hits.java:132)
at org.neo4j.index.impl.lucene.Hits.<init>(Hits.java:105)
at org.neo4j.index.impl.lucene.LuceneIndex.search(LuceneIndex.java:381)
at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:282)
at org.neo4j.index.impl.lucene.LuceneIndex.get(LuceneIndex.java:206)
at neo4j.Neo4J.GetNode(Neo4J.java:64)
at neo4j.Neo4J.GetStressTest1(Neo4J.java:122)
at neo4j.Neo4J.main(Neo4J.java:46)
Java Result: 1
BUILD SUCCESSFUL (total time: 13 minutes 48 seconds)