PDA

View Full Version : QGraphics scene use lagre memory count



Lokis
16th October 2013, 07:48
Good day. It was necessary for me write application which draw graph. For base code I used examles 40000 chips. Nodes and eges work correctly, but I have large problem. In some cases qt begin use lagre amount memory (gigabates). But it is not memory leak. I think that at use memory for intersection. So if reimplement function "shape" in class lines - qt don't demant memory. But in this case drawing will be wrong. How I can solve this problem with memory (if it is possible)?

Here is function where I create graph. It is im file GraphWidget.cpp


void GraphWidget::DoTestGraph()
{
QSharedPointer<GraphStruct> testGraph;
testGraph = QSharedPointer<GraphStruct>(new GraphStruct);
for (size_t ind = 0; ind < 100; ++ind) // Create nodes (Horizontal node count)
{
for (size_t jnd = 0; jnd < 100; ++jnd) // Vertical node count
{
GraphStruct::GraphVertex testvertex(QPoint(50*ind, 50*jnd), "node", "node_descr");
testGraph->vertexList.push_back(testvertex);
}
}
for (size_t ind = 0; ind < testGraph->vertexList.size() - 3; ++ind) // Create edges (links)
{
GraphStruct::GraphEdge testedge("link", "link_desc", 0/*to node*/, ind + 1/*from node*/); // Do all links to one node
testGraph->edgeList.push_back(testedge);
}
graphView->CreateGraph(testGraph);
}


At this place begin large memory allocation


#include "..\..\QueryClient\NewGUI\QT_graph\GraphWidget.h"
#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

ST::User::GraphWidget gw;
gw.show();

return a.exec(); // At this place begin large memory allocation
}


I attach files which necessary to compile project. If necessary change pos nodes or links when graph creates, so change function DoTestGraph