I have a model that contains one-to-one fields to other models. I over rid the save method to automatically assign these one-to-one fields. The problem is whenever I save this model, memory usage goes up by about 450k and is never released. The save method is as follows:
class Link(models.model):
id = models.CharField(max_length=11, primary_key=True)
fieldOne = models.OneToOneField(One, null=True, editable=False)
fieldTwo = models.OneToOneField(Two, null=True,, editable=False)
fieldThree = models.OneToOneField(Three, null=True,, editable=False)
def save(self, *args, **kwargs):
self.fieldOne = One.objects.get(id=self.id)
self.fieldTwo = Two.objects.get(id=self.id)
self.fieldThree = Three.objects.get(id=self.id)
super(Link, self)save(*args, **kwargs)
I believe the memory leak occurs at the line when objects.get() is called, since when I comment tem out, I noticed no increase in mem usage.