-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Unless I'm missing something, the addYield method leaks memory.
func (r *renderer) addYield(name string, binding interface{}) {
funcs := template.FuncMap{
"yield": func() (template.HTML, error) {
buf, err := r.execute(name, binding)
// return safe html here since we are rendering our own template
return template.HTML(buf.String()), err
},
"current": func() (string, error) {
return name, nil
},
}
r.t.Funcs(funcs)
}r.execute method Gets a buffer from the buffer pool, but the buffer is never Put back to the pool. I suggest getting rid of the r.execute method (it's two lines of code) and essentially in-lining its functionality. Doing so will allow deferring the buffer Put immediately after the the buffer Get. Seeing these paired together makes it much easier to ensure the buffer is returned.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels