You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Filip Maj (Commented) (JIRA)" <ji...@apache.org> on 2012/04/08 19:56:17 UTC

[jira] [Commented] (CB-461) Trying to insert bulk of data

    [ https://issues.apache.org/jira/browse/CB-461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13249584#comment-13249584 ] 

Filip Maj commented on CB-461:
------------------------------

You are probably doing something like:

{code}
for (var i = 0, l = 1000; i < l; i++) {
    insertARow(); // calls into Storage.java
}
{code}

Check this Stackoverflow thread out: http://stackoverflow.com/questions/6291692/why-is-phonegap-android-app-crashing-while-inserting-bunch-of-data-into-sql

Looks like: if you are making greater than 512 calls into native code from JavaScript in a *very* short amount of time, the JNI reference table doesn't have time to purge itself, and you crash.

Suggestions:

* use a larger transaction size to limit the number of INSERT calls being sent to Java
* use the accepted Answer in the SO post above to "reset" the functional scope in JavaScript and force the reference table to purge itself. Essentially wrap your JS call to Storage.java in an anonymous function that executes itself immediately

Hope that helps.
                
> Trying to insert bulk of data
> -----------------------------
>
>                 Key: CB-461
>                 URL: https://issues.apache.org/jira/browse/CB-461
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 1.5.0
>         Environment: Android, Cordova, JQuery Mobile
>            Reporter: Jawwad Farooq
>            Assignee: Joe Bowser
>              Labels: Android, Plugin, Storage
>
> I tweaked Storage.java class to use it for database related work instead of WebSQL for Android. Everything is working fine unless I have requirement to insert more than 600 rows in a go. When I tried to insert so many rows, around 500 rows were inserted successfully but after that following error occurs:
> W/dalvikvm(16890): ReferenceTable overflow (max=512)
> W/dalvikvm(16890): Last 10 entries in JNI local reference table:
> W/dalvikvm(16890):   502: 0x44a9e110 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   503: 0x44a9e908 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   504: 0x44a9e908 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   505: 0x44a9f358 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   506: 0x44a9f358 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   507: 0x44a9fca0 cls=Ljava/lang/String; (36 bytes)
> W/dalvikvm(16890):   508: 0x44a9fca0 cls=Ljava/lang/String; (36 bytes)
> W/dalvikvm(16890):   509: 0x44b94180 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   510: 0x44b94180 cls=Ljava/lang/String; (28 bytes)
> W/dalvikvm(16890):   511: 0x449a6768
> cls=Lcom/nubinews/reader/Reader$RuntimeJSInterface; (12 bytes)
> W/dalvikvm(16890): JNI local reference table summary (512 entries):
> W/dalvikvm(16890):     1 of Ljava/lang/Class; 164B
> W/dalvikvm(16890):   507 of Ljava/lang/String; 28B (432 unique)
> W/dalvikvm(16890):     3 of Ljava/lang/String; 36B (2 unique)
> W/dalvikvm(16890):     1 of Lcom/nubinews/reader/Reader$RuntimeJSInterface; 12B
> W/dalvikvm(16890): Memory held directly by tracked refs is 12344 bytes
> E/dalvikvm(16890): Failed adding to JNI local ref table (has 512 entries)
> ..... and so on. Then I tried to figure out is this the problem of SQLiteDatabase class or some Cordova related. So I commented out the actual database insertions in Storage.java. But the problem persisted. 
> So, I came to a point that if you call a plugin for more than 512 times from a single Javascript method, this exception will occur. Kindly look it in to this issue and let me know as I am badly stuck at this point.
> Thanks for your time. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira