java - performance issue LibGdx Box2d -


i have performance issue while update/render bodies(mobs) can see photo bellow many bodies add memory(private working set) cpu increased example if add 100 bodies move random in map merory(private working set) reach 900.000k going on? doing wrong? image url : http://prntscr.com/7l31tn

enter image description here

mob initialization ->>

private void initializeentityintoworld() {        //initializethemob       bodydef bodydef = new bodydef();       fixturedef fixturedef = new fixturedef();       polygonshape boxshape = new polygonshape();        bodydef.position.set(6,3);       bodydef.type=bodytype.dynamicbody;       bodydef.fixedrotation=true;       body = world.createbody(bodydef);       body.setuserdata(this);         boxshape.setasbox(width_meter, height_meter);       fixturedef.shape=boxshape;       fixturedef.filter.categorybits = constants.bit_player;       fixturedef.filter.maskbits = constants.bit_ground;       fixturedef.density = 1;       fixturedef.friction = 0f;       body.createfixture(fixturedef).setuserdata("mob");        body.setgravityscale(0);         boxshape.dispose();  }    @override public void update(float deltatime) {     super.update(deltatime);      } @override public void render(spritebatch batch) {     super.render(batch);      sprite sprite = new sprite(currentframe);     sprite.setsize(width_meter*2,height_meter*2);     sprite.setorigin(sprite.getwidth()/2, sprite.getheight()/2);       sprite.setrotation(body.getangle() * mathutils.radianstodegrees);     sprite.setposition(body.getposition().x-sprite.getoriginx(), body.getposition().y-sprite.getoriginy());     sprite.draw(batch);    } 

level class update/render bodies

    public void render(spritebatch batch){       (entity entity : dynamicentitysdestroyed)           world.destroybody(entity.getbody());     dynamicentitysdestroyed.clear();      for(int i=0;i<dynamicentitys.size;i++) dynamicentitys.get(i).render(batch);  } public void update(float deltatime){      for(int i=0;i<dynamicentitys.size;i++){         entity entity=dynamicentitys.get(i);         if(entity.isremoved())              dynamicentitys.removeindex(i);         else entity.update(deltatime);     }  } public void addentity(entity entity){     dynamicentitys.add(entity); } public void destroyentity(entity entity) {     dynamicentitysdestroyed.add(entity);  } 


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -