如何阻止过多的对象创建的三星手机? [英] How to stop excessive Object creation on Samsung phones?

查看:276
本文介绍了如何阻止过多的对象创建的三星手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,动画减慢在许多Android的三星手机。我已经追查问题实在是太多了垃圾收集。然而,没有任何对象都直接由我code创建。

I am have problems with animations slowing down on many Android Samsung phones. I have traced the problem and it is too much garbage collection. However, none of the objects are being created directly by my code.

这是从DDMS的配置跟踪的堆栈跟踪。

This is the stack trace from the Allocation Tracker in DDMS.

  at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:493) 
  at com.samsung.android.multiwindow.MultiWindowStyle$1.createFromParcel(MultiWindowStyle.java:491) 
  at com.samsung.android.multiwindow.IMultiWindowFacade$Stub$Proxy.getMultiWindowStyle(IMultiWindowFacade.java:499) 
  at com.samsung.android.multiwindow.MultiWindowFacade.getMultiWindowStyle(MultiWindowFacade.java:81)   
  at android.app.Activity.getMultiWindowStyle(Activity.java:4681)   
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1688)    
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1264)  
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6614)    
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)  
  at android.view.Choreographer.doCallbacks(Choreographer.java:613) 
  at android.view.Choreographer.doFrame(Choreographer.java:583) 
  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)   
  at android.os.Handler.handleCallback(Handler.java:733)    
  at android.os.Handler.dispatchMessage(Handler.java:95)    
  at android.os.Looper.loop(Looper.java:146)    
  at android.app.ActivityThread.main(ActivityThread.java:5678)  

这是创造数以千计的矩形和点对象,当用户触摸屏幕。

This is creating thousands of Rect and Point objects when the user touches the screen.

有谁知道一个变通?

我不是针对三星手机,或者使用与他们的软件开发工具包或库。

I am not targeting Samsung phones or using and of their sdks or libraries.

推荐答案

那么,有一种设计模式开始发挥作用,我们使用了这样的情况,被称为轻量级的模式。不知道这是否可以帮助你,如果客户端code是你的控制之下,如果是这样,而是使新的对象,使用相同的对象,与对象的属性(例如矩形会有x,y坐标)存储在数组中的客户对象,并调用Rect物件上的拉伸方法,传递存储在所述客户端中的阵列中的矩形对象的坐标。

Well, there is a design pattern comes into play which we use for situation like this, Called flyweight pattern. Not sure if this helps you if the client code is under your control , if it is , rather making the new objects, use the same object, with the properties of the object ( for example Rect will have x,y coordinates ) stored in the client object in an array , and call the draw method on the Rect object , passing the coordinates of the rect object stored in the array in the client.

这篇关于如何阻止过多的对象创建的三星手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆