本文介绍了在Android RequestFactory放缓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RequestFactory与应用程序引擎和Android。它一直致力于伟大的,但是当我检索任意大小的物体(约400)的列表,它有一个非常滞后的响应。看来,数据传输相当快(〜4秒)发生的,但是我没有得到的onSuccess()回调,直到很久以后(1-2分钟或更大)。我猜测,这可能是在requestfactory解析的性能下降。我的对象只是的POJO文本约10场和长。

我的问题是有没有人遇到过吗?任何人有一个更有效的方式来获得大量的数据,关闭应用程序引擎的迅速机器人?

更新:我也有使用RF有很多实体(3000+)时,遇到了OutOfMemoryError异常。我切换到直JSON使用GSON lib和解析的速度更快,并没有碰到内存的问题呢。

具体的实体,我送过线低于(我用物化)。

  @Cached
@实体
公共类InterestPoint
{
@Id
@GeneratedValue(策略= GenerationType.IDENTITY)
私人龙ID;

私人龙的groupId;
私人字符串更多的数据;
@Unindexed
私人诠释纬度,隆基;
@Unindexed
私人字符串的地址,城市,州;
@Unindexed
私人诠释NUM1,NUM2,NUM3;
@Unindexed
私人诠释num4,num5,NUM6;
@Unindexed
私人字符串名称;
@Unindexed
私人诠释MOREDATA;
@Unindexed
私人字符串说明;
}
 

解决方案

添加到笔者的问题的说明

我们正在获取8相对小的物体,每个人都有这是微小的一至四个子对象:

下面是堆栈的例子后的反应已经从服务器返回,超过一分钟,它在org.json包或com.google.web.bindery,我们有很高的CPU占用率:

  java.lang.AbstractStringBuilder append0 AbstractStringBuilder.java 143假
java.lang.StringBuilder中追加StringBuilder.java 125假
org.json.JSONStringer字符串JSONStringer.java 344假
org.json.JSONStringer值JSONStringer.java 252假
org.json.JSONObject报价JSONObject.java 713假
com.google.web.bindery.autobean.shared.impl.StringQuoter报价StringQuoter.java 69假
com.google.web.bindery.autobean.shared.impl.StringQuoter创建StringQuoter.java 50假
com.google.web.bindery.autobean.shared.Value codeX $输入$ 13 CHS code值codex.java 193假
com.google.web.bindery.autobean.shared.Value codeX连接code值codex.java 315假
com.google.web.bindery.autobean.shared.impl.AutoBean codexImpl $值codeR extractSplittable AutoBean codexImpl.java 500假
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean的SetProperty AbstractAutoBean.java 277假
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean的SetProperty ProxyAutoBean.java 253假
com.google.web.bindery.autobean.vm.impl.BeanPropertyContext设置BeanPropertyContext.java 44假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext $ 3 visitValueProperty AbstractRequestContext.java 910假
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean traverseProperties ProxyAutoBean.java 289假
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean遍历AbstractAutoBean.java 166假
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean接受AbstractAutoBean.java 101假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext processReturnOperation AbstractRequestContext.java 879假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext processReturnOperations AbstractRequestContext.java 1215假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext获得$ 600个AbstractRequestContext.java 76假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext $ StandardPayloadDialect processPayload AbstractRequestContext.java 347假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext $ 5 onTransportSuccess AbstractRequestContext.java 1108假
com.whichfestival.AndroidRequestTransport发送AndroidRequestTransport.java 68假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext doFire AbstractRequestContext.java 1102假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext火AbstractRequestContext.java 569假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest火AbstractRequest.java 54假
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest火AbstractRequest.java 59假
com.whichfestival.FetchTopService getEvents FetchTopService.java 99假
com.whichfestival.FetchTopService onHandleIntent FetchTopService.java 56假
android.app.IntentService $ ServiceHandler的handleMessage IntentService.java 59假
android.os.Handler在DispatchMessage Handler.java 99假
android.os.Looper环Looper.java 130假
android.os.HandlerThread运行HandlerThread.java 60假
 

和我们看到GC踢在25倍左右:

  11-16 22:30:28.464:D / dalvikvm(416):GC_CONCURRENT释放930K,51%免费3321K / 6727K,外部1654K / 2137K,暂停15ms的10ms的+

11-16 22:30:33.605:D / dalvikvm(416):GC_CONCURRENT释放515K,49%免费3452K / 6727K,外部1654K / 2137K,暂停10毫秒+ 13毫秒

11-16 22:30:37.554:D / dalvikvm(416):GC_CONCURRENT释放638K,49%免费3497K / 6727K,外部1654K / 2137K,暂停11毫秒,10毫秒+

11-16 22:30:43.424:D / dalvikvm(416):GC_CONCURRENT释放681K,47%免费3572K / 6727K,外部1654K / 2137K,暂停为6ms + 9ms的
 

所有约15个小型的POJO ......将AP preciate任何帮助。绝对不顾一切地解决这个问题。

I am using RequestFactory with appengine and android. It has been working great, however when I retrieve a list of objects of any size(around 400) it has a very delayed response. It appears that the transfer of data happens fairly quickly(~4 secs), however I do not get the onSuccess() callback until much later(1-2 mins or greater). I am guessing this could be slow performance of parsing within requestfactory. My objects are just POJOs with about 10 fields of text and longs.

My question is has anyone come across this? Anyone have a more efficient way to get lots of data off of appengine quickly in android?

UPDATE: I also have ran into outofmemoryerrors when using RF with lots of entities(3000+). I switched to straight json using the GSON lib and parsing was quicker and have not ran into memory problems yet.

The specific Entity I am sending over the wire is below(I am using Objectify).

@Cached
@Entity
public class InterestPoint
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Long groupId;
private String more, data;
@Unindexed
private int lat, longi;
@Unindexed
private String address, city, state;
@Unindexed
private int num1, num2, num3;
@Unindexed
private int num4,num5,num6;
@Unindexed
private String name;
@Unindexed
private int moreData;
@Unindexed
private String notes;
}
解决方案

Adding to the author's description of the problem

We're retrieving 8 relatively small objects and each has one to four child objects which are tiny:

Here's an example of the stack after the response has been returned from the server, for over a minute it's in the org.json package or com.google.web.bindery and we have high cpu usage:

java.lang.AbstractStringBuilder append0 AbstractStringBuilder.java  143 false
java.lang.StringBuilder append  StringBuilder.java  125 false
org.json.JSONStringer   string  JSONStringer.java   344 false
org.json.JSONStringer   value   JSONStringer.java   252 false
org.json.JSONObject quote   JSONObject.java 713 false
com.google.web.bindery.autobean.shared.impl.StringQuoter    quote   StringQuoter.java   69  false
com.google.web.bindery.autobean.shared.impl.StringQuoter    create  StringQuoter.java   50  false
com.google.web.bindery.autobean.shared.ValueCodex$Type$13   encode  ValueCodex.java 193 false
com.google.web.bindery.autobean.shared.ValueCodex   encode  ValueCodex.java 315 false
com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl$ValueCoder    extractSplittable   AutoBeanCodexImpl.java  500 false
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    setProperty AbstractAutoBean.java   277 false
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   setProperty ProxyAutoBean.java  253 false
com.google.web.bindery.autobean.vm.impl.BeanPropertyContext set BeanPropertyContext.java    44  false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$3  visitValueProperty  AbstractRequestContext.java 910 false
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   traverseProperties  ProxyAutoBean.java  289 false
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    traverse    AbstractAutoBean.java   166 false
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    accept  AbstractAutoBean.java   101 false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperation  AbstractRequestContext.java 879 false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperations AbstractRequestContext.java 1215    false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    access$600  AbstractRequestContext.java 76  false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$StandardPayloadDialect processPayload  AbstractRequestContext.java 347 false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5  onTransportSuccess  AbstractRequestContext.java 1108    false
com.whichfestival.AndroidRequestTransport   send    AndroidRequestTransport.java    68  false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    doFire  AbstractRequestContext.java 1102    false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    fire    AbstractRequestContext.java 569 false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    54  false
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    59  false
com.whichfestival.FetchTopService   getEvents   FetchTopService.java    99  false
com.whichfestival.FetchTopService   onHandleIntent  FetchTopService.java    56  false
android.app.IntentService$ServiceHandler    handleMessage   IntentService.java  59  false
android.os.Handler  dispatchMessage Handler.java    99  false
android.os.Looper   loop    Looper.java 130 false
android.os.HandlerThread    run HandlerThread.java  60  false

And we see the GC kick in about 25 times:

11-16 22:30:28.464: D/dalvikvm(416): GC_CONCURRENT freed 930K, 51% free 3321K/6727K, external 1654K/2137K, paused 15ms+10ms

11-16 22:30:33.605: D/dalvikvm(416): GC_CONCURRENT freed 515K, 49% free 3452K/6727K, external 1654K/2137K, paused 10ms+13ms

11-16 22:30:37.554: D/dalvikvm(416): GC_CONCURRENT freed 638K, 49% free 3497K/6727K, external 1654K/2137K, paused 11ms+10ms

11-16 22:30:43.424: D/dalvikvm(416): GC_CONCURRENT freed 681K, 47% free 3572K/6727K, external 1654K/2137K, paused 6ms+9ms

all for about 15 small pojos... would appreciate any help. Absolutely desperate to solve this.

这篇关于在Android RequestFactory放缓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:09