开发者

OutOfMemoryError: Java heap space GoogleAppEngine

Got an application running on AppEngine. Has been running fine for 2 years. Checked in on it today and I discoverd it was failing. I have not touch the code for a long time.

The error I get is this:

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.appeng开发者_如何学Pythonine.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)

The code at line 132 in my proxy servlet access a list of entities I retrived from the database. It's this line "System.out.println("from db "+allEventsLst.size());"

My application works when I run a local server. Any ideas???

    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) {

Thanks


Not exactly sure but could be that the List is lazy loaded and when you call the size method it has to load all the elements. As your application has been running for awhile it may have enough elements to cause the out of memory problem.


Check the number of rows that is being returned from your source. Odds are, there is significantly more rows than normal and your data source doesn't have cursor'ing enabled, so the driver is trying to load all of the rows into memory and then running out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜