#17619: MemoryError when deleting objects with many generic relations
--------------------------------------+--------------------
     Reporter:  bjourne@…             |      Owner:  nobody
         Type:  Bug                   |     Status:  new
    Component:  contrib.contenttypes  |    Version:  1.3
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 When I delete an object which has several generic relations pointing to
 it, I get a memory error. It seems like there is some memory leak or
 infinite recursion going on because the process just locks up for a few
 seconds while the Python process grows to 3gb in size and then terminates
 with the MemoryError.

 I don't have an isolated test case for it, but the problem is easy for me
 to reproduce and I can provide more details if requested. Here is the full
 traceback:


 {{{
 In [9]: g = Game.objects.get(id = 34519)

 In [10]: g.delete()

 MemoryError                               Traceback (most recent call
 last)

 /app/tngfooty/<ipython console> in <module>()

 /usr/local/lib/python2.7/dist-packages/django/db/models/base.pyc in
 delete(self, using)
     578
     579         collector = Collector(using=using)
 --> 580         collector.collect([self])
     581         collector.delete()
     582

 /usr/local/lib/python2.7/dist-packages/django/db/models/deletion.pyc in
 collect(self, objs, source, nullable, collect_related, source_attr,
 reverse_dependency)
     176             for relation in model._meta.many_to_many:
     177                 if not relation.rel.through:
 --> 178                     sub_objs =
 relation.bulk_related_objects(new_objs, self.using)
     179                     self.collect(sub_objs,
     180                                  source=model,

 /usr/local/lib/python2.7/dist-
 packages/django/contrib/contenttypes/generic.pyc in
 bulk_related_objects(self, objs, using)
     183
     184         """
 --> 185         return
 self.rel.to._base_manager.db_manager(using).filter(**{
     186                 "%s__pk" % self.content_type_field_name:
     187
 ContentType.objects.db_manager(using).get_for_model(self.model).pk,

 /usr/local/lib/python2.7/dist-packages/django/db/models/manager.pyc in
 db_manager(self, using)
      90
      91     def db_manager(self, using):
 ---> 92         obj = copy.copy(self)
      93         obj._db = using
      94         return obj

 /usr/lib/python2.7/copy.pyc in copy(x)
      86         reductor = getattr(x, "__reduce_ex__", None)
      87         if reductor:
 ---> 88             rv = reductor(2)
      89         else:
      90             reductor = getattr(x, "__reduce__", None)

 /usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in
 __getstate__(self)
      60         """
      61         # Force the cache to be fully populated.

 ---> 62         len(self)
      63
      64         obj_dict = self.__dict__.copy()

 /usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in
 __len__(self)
      80                 self._result_cache = list(self._iter)
      81             else:
 ---> 82                 self._result_cache = list(self.iterator())
      83         elif self._iter:
      84             self._result_cache.extend(self._iter)

 /usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in
 iterator(self)
     284                 else:
     285                     # Omit aggregates in object creation.

 --> 286                     obj = model(*row[index_start:aggregate_start])
     287
     288                 # Store the source database of the object


 /usr/local/lib/python2.7/dist-packages/django/db/models/base.pyc in
 __init__(self, *args, **kwargs)
     274
     275     def __init__(self, *args, **kwargs):
 --> 276         signals.pre_init.send(sender=self.__class__, args=args,
 kwargs=kwargs)
     277
     278         # Set up the storage for instance state


 /usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.pyc in
 send(self, sender, **named)
     170
     171         for receiver in self._live_receivers(_make_id(sender)):
 --> 172             response = receiver(signal=self, sender=sender,
 **named)
     173             responses.append((receiver, response))
     174         return responses

 MemoryError:

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17619>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to