OutOfMemoryError:Java堆空间GoogleAppEngine

时间:2011-04-06 18:27:47

标签: java google-app-engine

在AppEngine上运行应用程序。已经运行了2年。今天检查了它,我发现它失败了。我很长时间没有触摸过代码。

我得到的错误是:

java.lang.OutOfMemoryError: Java heap space
at com.google.storage.onestore.v3.OnestoreEntity$Property.<init>(OnestoreEntity.java:2849)
at com.google.storage.onestore.v3.OnestoreEntity$EntityProto.addProperty(OnestoreEntity.java:5755)
at com.google.storage.onestore.v3.OnestoreEntity$EntityProto.merge(OnestoreEntity.java:6232)
at com.google.apphosting.api.DatastorePb$QueryResult.merge(DatastorePb.java:13045)
at com.google.appengine.repackaged.com.google.io.protocol.ProtocolMessage.mergeFrom(ProtocolMessage.java:405)
at com.google.appengine.repackaged.com.google.io.protocol.ProtocolMessage.mergeFrom(ProtocolMessage.java:422)
at com.google.appengine.repackaged.com.google.io.protocol.ProtocolMessage.parseFrom(ProtocolMessage.java:534)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.wrap(DatastoreApiHelper.java:90)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.wrap(DatastoreApiHelper.java:83)
at com.google.appengine.api.utils.FutureWrapper.wrapAndCache(FutureWrapper.java:51)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:67)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:71)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:32)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:69)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:56)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.ensureLoaded(QueryResultIteratorImpl.java:156)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.hasNext(QueryResultIteratorImpl.java:65)
at org.datanucleus.store.appengine.query.RuntimeExceptionWrappingIterator$1.get(RuntimeExceptionWrappingIterator.java:50)
at org.datanucleus.store.appengine.query.RuntimeExceptionWrappingIterator$1.get(RuntimeExceptionWrappingIterator.java:47)
at org.datanucleus.store.appengine.query.QueryExceptionWrappers$1.get(QueryExceptionWrappers.java:51)
at org.datanucleus.store.appengine.query.QueryExceptionWrappers$2.get(QueryExceptionWrappers.java:86)
at org.datanucleus.store.appengine.query.RuntimeExceptionWrappingIterator.hasNext(RuntimeExceptionWrappingIterator.java:105)
at org.datanucleus.store.appengine.query.LazyResult.resolveAll(LazyResult.java:115)
at org.datanucleus.store.appengine.query.LazyResult.size(LazyResult.java:110)
at org.datanucleus.store.appengine.query.StreamingQueryResult.size(StreamingQueryResult.java:130)
at guestbook.ProxyServlet.processRequest(ProxyServlet.java:132)
at guestbook.ProxyServlet.doGet(ProxyServlet.java:288)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)

我的代理servlet中第132行的代码访问我从数据库中检索的实体列表。它就是这行“System.out.println(”来自db“+ allEventsLst.size());”

我的应用程序在运行本地服务器时有效。任何想法???

    String fromDateStr = shortDf.format(fromDate);



    Query query = pm.newQuery(Event.class, "date >= fromDate");
      query.declareImports("import java.lang.String");
      query.declareParameters("String fromDate");    

    List<Event> allEventsLst = (List<Event>)query.execute(fromDateStr);

    System.out.println("from db "+allEventsLst.size());

    Map<String, Event> eventMap = new HashMap<String, Event>();

    for (Event e : allEventsLst) {

由于

2 个答案:

答案 0 :(得分:1)

不完全确定但可能是List是延迟加载的,当你调用size方法时,它必须加载所有元素。由于您的应用程序已运行一段时间,因此可能有足够的元素导致内存不足问题。

答案 1 :(得分:0)

检查从源返回的行数。可能的是,行数明显多于正常情况,并且您的数据源没有启用游标,因此驱动程序尝试将所有行加载到内存中然后耗尽。