1
class queryFactory(object):

    def __init__(self, request, sql,params):
        self.request=request
        self.sql=sql
        self.params=params


    def run_it(self):
        def getQuery():
            return dbpool.runQuery(self.sql, self.params)

        def onResult(data):
            self.request.write("done")
            self.request.finish()

        d = getQuery()
        d.addCallback(onResult)
        return NOT_DONE_YET

i created the above class from my render_POST and returned the run_it method of it's instance

However, when self.sql query returns huge data with memory usage reaching 500mb, i noticed the memory is never returned back to the OS, the process just holds on to it until i restart the application. i even did a gc.collect() right inside onResult with no luck.

Why is this so?

NOTE: i had to remove other codes from onResult just so i can narrow it down that i really didn't use the 'data' passed into onResult.

Bahrom
  • 4,752
  • 32
  • 41

0 Answers0