android - My Game has a memory leak -


i working on simple game. monitoring heap size , increasing max limit of 48mb. however, don't see in code cause such high memory usage. doing drawing 9 circles on screen , setting shadow around them. appreciated thanks!

 public void run() {     log.d("speed buttons", "background thread has started");     //standard game loop     canvas canvas;     while(isrunning == true)     {            if(!holder.getsurface().isvalid()) {             continue;         }          canvas = holder.lockcanvas();         //call dodraw method         dodraw(canvas);           holder.unlockcanvasandpost(canvas);      }   }   protected void dodraw(canvas canvas) {     paint circle = new paint();     circle.setcolor(color.blue);      //creates glow around circles     circle.setshadowlayer(5,0,0,color.red);      op.setwidthsetheight(getwidth(), getheight());     int big = 130;     op.setbig(130);       //i have use getwidth , getheight in draw, because in context, include title bar , status bar     //circle 5     //using convertdp pixel      canvas.drawcircle(getwidth()/2,getheight()/2,op.convertdptopixel(6000),circle);      //circle 2     canvas.drawcircle(getwidth()/2,getheight()/2-big*scale,op.convertdptopixel(6000),circle);     //circle 1     canvas.drawcircle(getwidth()/2-(big*scale),getheight()/2-big*scale,op.convertdptopixel(6000),circle);     //circle 3     canvas.drawcircle(getwidth()/2+ (big*scale),getheight()/2-big*scale,op.convertdptopixel(6000),circle);     //circle 8     canvas.drawcircle(getwidth()/2,getheight()/2+big*scale,op.convertdptopixel(6000),circle);     //circle 4     canvas.drawcircle(getwidth()/2-(big*scale),getheight()/2,op.convertdptopixel(6000),circle);     //circle 6     canvas.drawcircle(getwidth()/2+(big*scale),getheight()/2,op.convertdptopixel(6000),circle);     //circle 7     canvas.drawcircle(getwidth()/2-(big*scale),getheight() / 2 + big * scale, op.convertdptopixel(6000), circle);     //circle 9     canvas.drawcircle(getwidth()/2+(big*scale),getheight()/2+big*scale,op.convertdptopixel(6000),circle);           } 

it's possible calls drawcircle creating local variables in heap. garbage collector should take care of them, why it's capping off. having problems? or concern?


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -