I found out that LIBGDX allocates a lot of variables (not from any of my methods). I just ran the game for a few seconds and I've already got 32000 rows in DDMS->Allocation Tracker. The methods that allocate are getPalmRejection
, createFromParcel
and nativeReadString
. Is it normal to have this many allocations in just a couple of seconds?
I get 60FPS but sometimes it drops to 58-59 and that is important because I use framerate-independent movement in my game and I get alot of sprite-jolts (sprite-jumps) when this FPS drop happens.
Here are the stack traces :
**createFromParcel**
at android.graphics.Rect$1.createFromParcel(Rect.java:562)
at android.graphics.Rect$1.createFromParcel(Rect.java:557)
at com.samsung.android.multiwindow.MultiWindowStyle.readFromParcel(MultiWindowStyle.java:278)
at com.samsung.android.multiwindow.MultiWindowStyle.<init>(MultiWindowStyle.java:141)
at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:284)
at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:282)
at com.samsung.android.multiwindow.IMultiWindowFacade$Stub$Proxy.getMultiWindowStyle(IMultiWindowFacade.java:467)
at com.samsung.android.multiwindow.MultiWindowFacade.getMultiWindowStyle(MultiWindowFacade.java:53)
at android.app.ActivityThread.getAppMultiWindowStyle(ActivityThread.java:5368)
at android.app.ContextImpl.getAppMultiWindowStyle(ContextImpl.java:2698)
at android.content.ContextWrapper.getAppMultiWindowStyle(ContextWrapper.java:690)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6324)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6307)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6278)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6243)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6483)
**<init>**
at com.samsung.android.multiwindow.MultiWindowStyle.<init>(MultiWindowStyle.java:40)
at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:284)
at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:282)
at com.samsung.android.multiwindow.IMultiWindowFacade$Stub$Proxy.getMultiWindowStyle(IMultiWindowFacade.java:467)
at com.samsung.android.multiwindow.MultiWindowFacade.getMultiWindowStyle(MultiWindowFacade.java:53)
at android.app.ActivityThread.getAppMultiWindowStyle(ActivityThread.java:5368)
at android.app.ContextImpl.getAppMultiWindowStyle(ContextImpl.java:2698)
at android.content.ContextWrapper.getAppMultiWindowStyle(ContextWrapper.java:690)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6324)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6307)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6278)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6243)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6483)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
**getPalmRejection**
at android.view.ViewRootImpl.getPalmRejection(ViewRootImpl.java:3895)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6389)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6307)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6278)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6243)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6483)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6456)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6502)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:571)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
EDIT: One very probable cause is the MultiWindow feature of Samsung devices . Another possible cause of the allocations is in the methods of the touchDown event of the game screen:
@Override
public boolean touchDown (int x, int y, int pointer, int button) {
if ( (!spaces_can_explode && !paused_game_screen) && !spaces.exploded_finished && hud_display.startTimerFinished){
hud.touchDown(x, y, pointer, button, spaces, spaceship_bounding_rectangle, display_fud_camera, hud_display.startTimerFinished);
}
return false;
}
public void touchDown(int x, int y, int pointer, int button, Ship spaces, Rectangle shootHud, OrthographicCamera hud_cam, boolean startTimerFinished){
hud_cam.unproject(touchPoint.set(x, y,0));
pressed_middle_shoot = shootHud.contains(touchPoint.x, touchPoint.y);
if(!(pointer>1) && spaces.touch_upped){
pressed_left = (x < screen_sizewp3) && !pressed_middle_shoot;
pressed_right = (x > screen_sizewo2p3) && !pressed_middle_shoot;
pressed_middle = (!pressed_left && ! pressed_right);
if(!spaces.reversed_rotation ){
if(pressed_middle){
pressed_shoot = pressed_middle_shoot;
spaces.pressed_shoot = pressed_middle_shoot;
pressed_accel = !pressed_shoot;
spaces.pressed_accel = !pressed_shoot;
}
else if(pressed_left && !pressed_right){
if(spaces.sprite.getX() > spaces_maxleftplus){
spaces.touchDOWN(x, y, pointer, button, pressed_left, pressed_right, pressed_middle);
}
} else if (pressed_right && !pressed_left){
if(spaces.sprite.getX() < spaces_maxrightminus){
spaces.touchDOWN(x, y, pointer, button, pressed_left, pressed_right, pressed_middle);
}
}
}
}
pressed_left_hud = pressed_left;
pressed_right_hud = pressed_right;
pressed_shoot_once = pressed_middle_shoot;
}