java - libgdx: Why does my custom actor have a memory leak? -


i have created following custom actor draw lines on libgdx

public class linewidget extends actor implements disposable {  private position posa; private position posb;  public final vector2 _a; public final vector2 _b;  private textureregion linetexture; private final textureregion linetexturegreen = assets.instance.images.linegreen; private final textureregion linetextureorange = assets.instance.images.lineorange; private final textureregion linetexturered = assets.instance.images.linered;  public linewidget(position a, position b) {     this._a = a.getpositionvector();     this._b = b.getpositionvector();     this.posa = a;     this.posb = b; }  @override public void act(float delta) {     super.act(delta); }  @override public void draw(batch batch, float parentalpha) {     super.draw(batch, parentalpha);      setlinecolor(posa, posb);      float xdif = _b.x-_a.x;     float ydif = _b.y-_a.x;     float l2 = xdif*xdif+ydif*ydif;     float invl = (float)(1/math.sqrt(l2));     //dif vector length linewidth first second vertex     xdif*=invl*5;     ydif*=invl*5;      float floatbits = batch.getcolor().tofloatbits();     //draw quad width of linewidth*2 through (x1, y1) , (x2, y2)     float[] verts = new float[]{_a.x+ydif, _a.y-xdif, floatbits, linetexture.getu(), linetexture.getv(),             _a.x-ydif, _a.y+xdif, floatbits, linetexture.getu2(), linetexture.getv(),             _b.x-ydif, _b.y+xdif, floatbits, linetexture.getu2(), linetexture.getv2(),             _b.x+ydif, _b.y-xdif, floatbits, linetexture.getu(), linetexture.getv2()};     batch.draw(linetexture.gettexture(), verts, 0, 20); }  @override public void setsize(float width, float height) {     super.setsize(width, height); }  @override public void dispose() { }  private void setlinecolor(position a, position b) {     if(a.get_value() != null && b.get_value() != null) {         if(a.get_value() == 1 || b.get_value() == 1) {             linetexture = linetexturegreen;             return;         }else {             linetexture = linetexturered;         }     } else {         linetexture = linetexturered;     } } 

}

when create actor memory consumption keeps going cannot detect leak happening. how can fix actor stop leaking memory?

edit: drawing actor inside actor extends group actor class. group actor class not leak memory , thing doing draw linewidget calling addactor(). actor added stage inside screen. dont think information important adding in case. have tested actors , memory leak begins when draw linewidget actor.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -