Exceeded soft memory limit with basic SELECT
I have a datastore with a kind named MyUsers(db.Model)
that currently contains about 30 entities.
I have written a script that prints all the entities' "name" attribute to the screen (separated by the '#' char), using the following code:
def get(self):
q_1 = MyUsers.all().order('name')
for user in q_1:
self.response.out.write(user.name)
self.response.out.write("#")
The script works just fine, but the problem is that I always get critical message in the app engine log:
12-12 12:45AM 22.691
Exceeded soft memory limit with 220.043 MB after servicing 1 requests total
I 12-12 12:45AM 22.691
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
W 12-12 12:45AM 22.691
After handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application.
It seems like this is a very straightforward basic operation, that shouldn't exceed any memory limits, so what can I do to improve it?
Thanks,
Joel
EDIT:
As for the imports, the imports I use are:
from models.model import *
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import profiler.appengine.request
import profiler.appengine.datastore
I used a profiler to try and understand what is wrong, maybe you can help
Thanks!
Joel
EDIT 2
This is the full version of the code (the problem occurred also before I imported the profiler, I used it after it happened to try and debug):
from models.model import MyUsers
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import profiler.appengine.request
import profiler.appengine.datastore
class PrintAll(webapp.RequestHandler):
def get(self):
q_1 = MyUsers.all().order('name')
for user in q_1:
self.response.out.write(user.name)
self.response.out.write("#")
application = webapp.WSGIApplication(
[('/print', PrintAll)
],
开发者_如何学运维 debug=True)
def main():
profiler.appengine.request.activate()
profiler.appengine.datastore.activate()
run_wsgi_app(application)
profiler.appengine.request.show_summary()
profiler.appengine.datastore.show_summary()
profiler.appengine.datastore.dump_requests() # optional
if __name__ == "__main__":
main()
As for the MyUsers() model class:
class MyUsers(db.Model):
user = db.UserProperty()
points = db.FloatProperty()
bonus = db.FloatProperty(default=0.0)
joindate = db.DateTimeProperty(auto_now_add=True)
lastEntry=db.DateTimeProperty(auto_now_add=True)
name=db.StringProperty()
last_name = db.StringProperty()
homepage = db.StringProperty()
hobbies = db.ListProperty(str)
other = db.StringProperty()
calculate1 = db.FloatProperty()
calculate2 = db.FloatProperty()
calculate3= db.IntegerProperty(default=0)
history = db.ListProperty(str)
history2 = db.ListProperty(str)
title = db.IntegerProperty(default=0)
title_string = db.StringProperty()
updateDate = db.DateTimeProperty(auto_now_add=True)
level=db.IntegerProperty(default=0)
debug_helper=db.IntegerProperty(default=0)
debug_list=db.ListProperty(str)
As it stands, there's not really any way that this could cause the error you're seeing. Can you provide a complete reproduction case? It's likely that something other than the code snippet you've included is the cause of this issue.
精彩评论