PDA

View Full Version : Application very heavy for lots object



Kapil
29th April 2006, 07:54
Hi...

My Application has become very heavy and is taking lots of memory because of my use of lots of Q3CanvasLine Objects..

basically i want to draw 1000 canvas lines on a canvas...
so what i did was this..

CanvasDraw.cpp


Q3CanvasLine **m_pCLineObjs;

//in class contructor
m_pCLineObjs = new Q3CanvasLine*[1000];

// function -> drawLine()
for(i=0;i<1000;i++)
{

m_pCLineObjs[i] = new Q3CanvasLine(canvas);
m_pCLineObjs[i]->setPoints(//points set here);
m_pCLineObjs[i]->show();

}


After this i created 512 objects of the CanvasDraw class and then tried running the app... but then for each of the 512 objs it created 1000 lines... which makes in total 512 * 1000 lines being created making the application take hell lot of memory and making it very very heavy....

Is it possible for me to create a single line object like Q3CanvasLine *m_pCLine and then call this 1000 times to create 1000 lines at different places...
I tried somthing like this but then it was just creating one line at the last line points..

OR is there any solution which can help me creating least number of line objects to create the line..

Please help me out in this..

Thanking you,

with regards,
Kapil

jacek
29th April 2006, 17:33
If those lines only connect other objects, IMO you should draw them by hand without creating Q3CanvasLine.