【发布时间】:2010-08-17 10:23:23
【问题描述】:
这是我的函数的源代码:
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;
}
我的程序的内存使用量严格增加,但是当我删除nodeToReplace.parentNode().replaceChild(node,nodeToReplace); 行时,程序使用稳定的内存量。
我监控了fieldState(QDomDocument),但在我使用replaceChild 时它没有增长(我做了一些小改动)。有什么问题?
谢谢。
【问题讨论】:
标签: c++ xml debugging qt memory-leaks