Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
A huge "memleak" in a simple Django view
from django.http import HttpResponse
from .models import FirstModel
# this view will make crazy use of the RAM ;)
def my_view(request):
# this queryset contains about 100k records
# each of them has many ForeignKeys to other models
huge_queryset = FirstModel.objects.all()
f = open('dumb.dump', 'w')
for record in huge_queryset:
print >>f, record
return HttpResponse('Dumb dump completed!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.