Here is source code of my function:
bool FieldModel::updateNode(QDomNode &node,const QString &parent){
QDomElement rootOfTag;
rootOfTag=fieldState.firstChild().firstChildElement(parent);
qDebug()<<"Before"<<fieldState.toString();
QDomNodeList sameTags=rootOfTag.elementsByTagName(node.firstChild().toElement().tagName());
for(uint i=0;i<sameTags.length();i++){
QDomNode nodeToReplace=sameTags.item(i);
if(nodeToReplace.toElement().attribute("id")==node.firstChild().toElement().attribute("id")){
nodeToReplace.parentNode().replaceChild(node,nodeToReplace);//Cause Memory Leak
qDebug()<<"After"<<fieldState.toString();
return true;
}
}
insertNode(node,parent);
return true;
}
Memory usage of this my program strictly increases, but when I removed line nodeToReplace.parentNode().replaceChild(node,nodeToReplace);
, program uses stable amount of memory.
I monitored fieldState(QDomDocument)
, and it is not growing while I'm using replaceChild
(I make small changes). What can be problem?
Thanks.