Wednesday, October 12, 2011

Profile and reduce memory use in Django with .iterator()


  1. Comparing your two last examples, I don't understand how that change alone saves memory.

    Was the your "jobs" query exactly the same in both of those cases? Or did you use .iterator() in the latter example?

  2. If you reference fields on a list of objects that is still in scope, like jobs, each job record in the list will become fully populated with data from the database as you reference it, and that memory will not be freed until the entire jobs list goes out of scope.