I am running Django 1.2.1 with South 0.7.2 and DEBUG = False. Still a very simple data migration leaks memory:
def forwards(self, orm):
for tr in orm.TestResult.objects.all():
tr.software = tr.test_result.test_run.software
tr.save()
The amount of TestResults is pretty big, but that should not be a real problem besides a long runtime. Unfortunately the process grows till my machine is out of memory.
I finally found the solution to my problem to avoid the caching in the QuerySet:
for tr in orm.TestResult.objects.iterator() :
tr.software = ...
It was already asked on SO here:
Django : Iterate over a query set without cache
and the explanation in the Django docs:
http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator