OrientDB - does not free memory after insertion

I use NodeJS to insert 8,000,000 records into my orientdb database, but after about 2,000,000 insert records my application is stopped and shows a "Java Heap" error.

Is there any way to free memory after each inserted record?

Using the framework:
to start the application: 2.6g
-After entering 2million entries: 7.6g

My app.js (NodeJS):

var dbConn = [];
var dbNext = 0;
var dbMax = 25;

for (var i = 0; i <= dbMax; i++) {
  var db = new ODatabase({
      host: orientdb.host,
      port: 2424,
      username: 'root',
      password: orientdb.password,
      name: 'test',
  });
  dbConn.push(db);
}
//---------------------------------------------------
//Start loop
// record = {name: 'test'}
record["@class"] = "table";
var db = nextDB();
db.open().then(function () {
    return db.record.create(record);
}).then(function (res) {
    db.close().then(function () {
             //----resume loop
    });
  }).error(function (err) {
          //------
  });
// end loop - iteration loop
//---------------------------------------------------
function nextDB() {
  if (++dbNext >= dbMax) {
      dbNext -= dbMax;
  }
  return dbConn[dbNext];
}
+4
source share
2 answers

OrientJS SqlServer OrientDB. ETL , transpot 2 .
7000 .

ETL config.json:

{
  "config": {
    log : "debug"
  },
  "extractor" : {
    "jdbc": { "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
              "url": "jdbc:sqlserver://10.10.10.10;databaseName=My_DB;",
              "userName": "sa",
              "userPassword": "123",
              "query": "select * from My_Table" 
            }
  },

  "transformers" : [
    { "vertex": { "class": "Company"} }
  ],
   "loader" : {
    "orientdb": {
      "dbURL": "plocal:D:\DB\Orient_DB",
      dbUser: "admin",
      dbPassword: "admin",
      "dbAutoCreate": true,
      "tx": false,
      "batchCommit": 1000,
      "wal" : false,
      "dbType": "graph"
    }
  }
}
+1

, :

db.declareIntent( new OIntentMassiveInsert() );
// YOUR MASSIVE INSERTION    
db.declareIntent( null );

, , orientJS. , / . , , .

node.js, - :

db.open().then(function () {
  // when available // db.declareIntent( new OIntentMassiveInsert() );
  for (var i = 0; i < 8000000; i++) {
    // create a new record
    myRecord = { "@class" : "myClass", "attributePosition" : i };
    db.record.create(myRecord);
  }
  // when available // db.declareIntent( null );

}).then(function () { db.close() });
0

Source: https://habr.com/ru/post/1666906/


All Articles