Last active
August 29, 2015 14:07
-
-
Save baxeico/81770fd076216523541a to your computer and use it in GitHub Desktop.
A huge "memleak" in a simple Django view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
f.close() | |
return HttpResponse('Dumb dump completed!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment