0

I am facing a problem of huge memory leak on a server, serving a Django (1.8) app with Apache or Ngnix (The issue happens on both).

When I go on certain pages (let's say on the specific request below) the RAM of the server goes up to 16 G in few seconds (with only one request) and the server freeze.

def records(request):
    """Return list 14 last records page. """
    values = []
    time = timezone.now() - timedelta(days=14)
    record =Records.objetcs.filter(time__gte=time)
    return render(request,
                  'record_app/records_newests.html',
                  {
                      'active_nav_tab': ["active", "", "", ""]
                      ' record': record, 
                  })

When I git checkout to older version, back when there was no such problem, the problem survives and i have the same issue.

I Did a memory check with Gumpy for the faulty request here is the result:

>>> hp.heap()
Partition of a set of 7042 objects. Total size = 8588675016 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0   1107  16 8587374512 100 8587374512 100 unicode
     1   1014  14   258256   0 8587632768 100 django.utils.safestring.SafeText
     2     45   1   150840   0 8587783608 100 dict of 0x390f0c0
     3    281   4    78680   0 8587862288 100 dict of django.db.models.base.ModelState
     4    326   5    75824   0 8587938112 100 list
     5     47   1    49256   0 8587987368 100 dict of 0x38caad0
     6     47   1    49256   0 8588036624 100 dict of 0x39ae590
     7     46   1    48208   0 8588084832 100 dict of 0x3858ab0
     8     46   1    48208   0 8588133040 100 dict of 0x38b8450
     9     46   1    48208   0 8588181248 100 dict of 0x3973fe0
<164 more rows. Type e.g. '_.more' to view.>
7
  • There isn't any information on here for us to go on, something you've added to those "certain" pages, requires a lot of memory
    – Sayse
    Commented Mar 23, 2016 at 13:59
  • You need to restart the server after reverting to the previous version of the code.
    – Alasdair
    Commented Mar 23, 2016 at 14:01
  • So when an issue is complicated you just put it on hold on ? Whatever thing i put on those "certain" pages is gone since I git checked out to a previous commit. And I am certain that this older commit hadn't the issue because this server is used by a lot of persons every day.
    – v.thorey
    Commented Mar 23, 2016 at 14:55
  • And for the "restart the server" I tryed of course. I even deployed on nginx (I was using apache first.) and the problem is still there
    – v.thorey
    Commented Mar 23, 2016 at 14:56
  • When I execute the view corresponding to one of the problematic page I get no problem so the issue is not a SQL request or in the code of the view.
    – v.thorey
    Commented Mar 23, 2016 at 14:57

1 Answer 1

1

After a day of search I found my answer.

While investigating I checked statistics on my DB and saw that some table was 800Mo big but had only 900 rows. This table contains a Textfield without max len. Somehow one text field got a huge amount of data inserted into and this line was slowing everything down on every pages using this model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.