My xml-file have more than 75000 nodes and I must placed this nodes in
ArrayList, but if count of this nodes exceeds
20000 I have memory overflow error.
Code:
public static void main(String[] args)
{
ArrayList<String[]> geoIp = new ArrayList<String[]>();
/*one node of geoip.xml (~75000 nodes): <country ip_start="2.6.190.56"
ip_end="2.6.190.63" num_ip_start="33996344"
num_ip_end="33996351" flag="GB" >United Kingdom</country>*/
QFile xmlFile = new QFile("geoip.xml");
if (!xmlFile.exists()) System.out.println("file not exists");
else
{
QDomDocument doc = new QDomDocument();
doc.setContent(xmlFile);
QDomElement docElement = doc.documentElement();
QDomElement node = docElement.firstChildElement();
while(!node.isNull())
{
String[] mas = new String[6];
mas[0] = node.attribute("ip_start");
mas[1] = node.attribute("ip_end");
mas[2] = node.attribute("num_ip_start");
mas[3] = node.attribute("num_ip_end");
mas[4] = node.attribute("flag");
mas[5] = node.text();
geoIp.add(mas);
/*with this line I have error of memory overflow, without it all normal*/
node = node.nextSiblingElement();
}
}
}
This example (whithout xml) works fine, we don't have memory overflow:
/*one line of geoip.txt:
"2.6.190.56","2.6.190.63","33996344","33996351","GB","United Kingdom"*/
QFile csvFile = new QFile("Presets/geoip.txt");
if (!csvFile.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.ReadOnly)))
return;
ArrayList baseList = new ArrayList();
while (!csvFile.atEnd())
{
String line = csvFile.readLine().toString();
String[] mas = line.split(",");
for (int i = 0; i < mas.length; i ++)
{
String str = mas[i];
mas[i] = str.replace("\"", "");
}
baseList.add(mas); //baseList contains all data of file (~75000 lines)
}
"VM Options: -Xmx512m" not help too.
I would not want to deviate from XML, advise something? Very thanks (sorry for
my english).
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest