Memory leak in Google ndb library

前端 未结 3 1051
旧巷少年郎
旧巷少年郎 2020-12-03 09:10

I think there is a memory leak in the ndb library but I can not find where.

Is there a way to avoid the problem described below?
Do you have a more

3条回答
  •  Happy的楠姐
    2020-12-03 09:27

    A possible workaround is to use context.clear_cache() and gc.collect() on get method.

    def get(self):
    
        for _ in range(10):
            for entity in DummyModel.query().iter():
                pass # Do whatever you want
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, World!')
        context = ndb.get_context()
        context.clear_cache()
        gc.collect()
    

提交回复
热议问题