#31582: Django template backend allocates model cache even iterator() is used
---------------------------------+--------------------------------------
     Reporter:  Sümer Cip        |                    Owner:  nobody
         Type:  Bug              |                   Status:  closed
    Component:  Template system  |                  Version:  3.0
     Severity:  Normal           |               Resolution:  needsinfo
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by Sümer Cip):

 Hi Keryn,

 I think you are exactly right about that:

 I traced memory allocation before/after that function call:

 {{{
 if not hasattr(values, '__len__'):
     print("render len enter", tracemalloc.get_traced_memory())
     values = list(values)
     print("render len exit", tracemalloc.get_traced_memory())
 '''
 render len enter (48421, 48653)
 render len exit (9390626, 9462231)
 '''
 }}}

 But we also have this afterwards in that function which complicates things
 more:

 {{{
 for node in self.nodelist_loop:
       nodelist.append(node.render_annotated(context))
 }}}

 {{{context}}} is pointing to the {{{item}}} which is the model itself!
 Even we fix above {{{len()}}} call somehow, this will hurt us again.

 I am not sure how to proceed further on this as this seems to require more
 internal Django knowledge than I have right now :)

 Any ideas?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31582#comment:4>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.45148fe09480349f8d2247efb298e84d%40djangoproject.com.

Reply via email to