Problem description
Parsing a large XML file fails using V8
Sample code and steps to reproduce
data.xml file is attached
App.js :
var file = Ti.Filesystem.getFile('data.xml');
var xmlData = file.read().text;
var xml = Ti.XML.parseString(xmlData);
var nodes = xml.documentElement.childNodes;
var i, j, k;
for (i = 0; i < nodes.length; i++) {
if (nodes.item(i).hasAttributes()) {
var attr = nodes.item(i).getAttributes();
for (j = 0; j < attr.length; j++) {
var nodeval = attr.item(j).nodeValue;
Ti.API.info(attr.item(j).nodeName + ': ' + nodeval);
}
}
// <text>
for (j = 0; j < nodes.item(i).childNodes.length; j++) {
if (nodes.item(i).childNodes.item(j).nodeName == 'text') {
var textNodes = nodes.item(i).childNodes.item(j);
var text = "";
for (k = 0; k < textNodes.childNodes.length; k++) {
text += textNodes.childNodes.item(k).nodeValue;
}
Ti.API.info(text);
}
}
}
Ti.API.info("Success!");
win.open();
iOS and Rhino run just fine, but V8 fails before finishing with:
09-09 17:29:08.808: E/dalvikvm(4734): JNI ERROR (app bug): weak global reference table overflow (max=51200)
09-09 17:29:08.812: W/dalvikvm(4734): JNI weak global reference table (0x4d433008) dump:
09-09 17:29:08.816: W/dalvikvm(4734): Last 10 entries (of 51200):
09-09 17:29:08.816: W/dalvikvm(4734): 51199: 0x419fa0f0 ti.modules.titanium.xml.ElementProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51198: 0x41a01a78 ti.modules.titanium.xml.NodeListProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51197: 0x41a06ec0 ti.modules.titanium.xml.ElementProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51196: 0x41a10708 ti.modules.titanium.xml.NodeListProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51195: 0x41a17080 ti.modules.titanium.xml.TextProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51194: 0x41a1e348 ti.modules.titanium.xml.NodeListProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51193: 0x41a237c0 ti.modules.titanium.xml.NodeListProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51192: 0x41a2a308 ti.modules.titanium.xml.ElementProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51191: 0x41a2d868 ti.modules.titanium.xml.NodeListProxy
09-09 17:29:08.816: W/dalvikvm(4734): 51190: 0x41a32178 ti.modules.titanium.xml.ElementProxy
09-09 17:29:08.901: W/dalvikvm(4734): Summary:
09-09 17:29:08.901: W/dalvikvm(4734): 1844 of ti.modules.titanium.xml.TextProxy (1844 unique instances)
09-09 17:29:08.905: W/dalvikvm(4734): 4423 of ti.modules.titanium.xml.ElementProxy (4423 unique instances)
09-09 17:29:08.905: W/dalvikvm(4734): 4426 of ti.modules.titanium.xml.NodeListProxy (4426 unique instances)
09-09 17:29:08.905: W/dalvikvm(4734): 367 of ti.modules.titanium.xml.NamedNodeMapProxy (367 unique instances)
09-09 17:29:08.909: W/dalvikvm(4734): 2944 of ti.modules.titanium.xml.AttrProxy (2944 unique instances)
Basically it seems like the Java-side proxies are not getting properly deleted when JS-scoping says they should be.
Confirmed. Moving to TiMOB
Cannot reproduce Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
Closing ticket as the issue cannot be reproduced and due to the above comments.