1

We've In-Line Javascript data like following with thousand of lines. I've observed that it is taking lot of memory too, this is a problem in mobile browsers. Does it help to move this code to some JSON File, and parsing it. I just want this code to GCed as soon as it is executed.

 db.transaction(function(tx) {
     transaction.executeSql("INSERT INTO TABLE VALUES(111,'xxx','2012-11-09 18:48:12')");
     ..... Another 10K Lines of above String .............
   }
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
coder000001
  • 476
  • 4
  • 22

1 Answers1

1

With about 10k of those lines, you have about half a MB of raw text going through your js, not to mention the fact that you're calling transaction.executeSql() about 10k times.

You could reduce that a bit by combining multiple (/all) INSERT INTO statements into a single statement:

INSERT INTO
    TABLE
VALUES
    (111,'xxx','2012-11-09 18:48:12'),
    (222,'yyy','2012-11-09 18:48:12'),
    (333,'zzz','2012-11-09 18:48:12')
    etc...
Cerbrus
  • 70,800
  • 18
  • 132
  • 147