I'm uploading images (<10MB each) to a simplified handler (below) to showcase this problem. After serving ~5 requests on an F1 (128MB of ram) instance I run over the memory limit: "Exceeded soft private memory limit with 152.414 MB after servicing 6 requests total"
On an F2 (256MB of ram) instance I get a few more requests in, but not many: "Exceeded soft private memory limit with 258.156 MB after servicing 19 requests total"
Example code:
import webapp2
class FileUploader(webapp2.RequestHandler):
def post(self):
test = self.request.get('file')
self.response.out.write('hi')
app = webapp2.WSGIApplication([('/leak-uploader-example', FileUploader)],
debug=True)
The text in the logs suggest my application may have a memory leak. It seems like the problem may be with either Python or App Engine garbage collecting after a request is complete. Any suggestions for how to keep my instances from being terminated after only a few requests?
update -- I'm seeing the same behavior using webapp framework (instead of webapp2): "Exceeded soft private memory limit with 143.121 MB after servicing 6 requests total"
Why not use Blobstore for your images? https://developers.google.com/appengine/docs/python/blobstore/#Python_Uploading_a_blob
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With