Scenario-
I am running B* instances on App Engine. I\'ve a background ETL related task(written in python) scheduled as a cron job on App Engine. Whe
There are a few questions on StackOverflow describing similar memory issues for tasks when using ndb on app engine. Here is one example.
The issue is that app engine doesn't clear the ndb context cache upon the conclusion of a task so context cache continues to hog your memory long after the task completes.
The solution is to not use or clear the context cache during your tasks. Here are a few ways:
key.get(use_cache=False)ndb.get_context().clear_cache() at appropriate times._use_cache = False to your model definition.