As Daniel said, QPainterPath is not part of Graphics View framework, it doesn't use BSP and can't benefit from what graphics view offers. If one runs out of memory (quite hard for me to believe it unless resources are limited by the system somehow) then we can't circumvent that. However to improve performance in GV, it is enough to split the painter path into separate items, as far as I rememeber, it makes a big difference. Caching is a must as well.
I just ran this small test program:
#include <QtGui>
#include <iostream>
int main(int argc, char **argv) {
for(int i=0;i<100000;++i) {
std::cerr << "Iteration " << i << "...";
path.lineTo(qrand() % 1000, qrand() % 1000);
std::cerr << "Done" << std::endl;
}
std::cerr << "Path ready" << std::endl;
// let's sleep now
s.acquire();
return 0;
}
#include <QtGui>
#include <iostream>
int main(int argc, char **argv) {
QPainterPath path;
for(int i=0;i<100000;++i) {
std::cerr << "Iteration " << i << "...";
path.lineTo(qrand() % 1000, qrand() % 1000);
std::cerr << "Done" << std::endl;
}
std::cerr << "Path ready" << std::endl;
// let's sleep now
QSemaphore s(0);
s.acquire();
return 0;
}
To copy to clipboard, switch view to plain text mode
The path was constructed fine, the system reports the following memory usage:
VmPeak: 89104 kB
VmSize: 89104 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 7240 kB
VmRSS: 7240 kB
VmData: 4468 kB
VmStk: 136 kB
VmExe: 8 kB
VmLib: 22452 kB
VmPTE: 192 kB
VmSwap: 0 kB
One can see the peak memory usage is 90MB, with 22MB taken by libraries and only 4.5MB taken by the heap. This gives 45 bytes per path segment (on a 64b system).
Bookmarks