You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I'm missing something, the addYield method leaks memory.
func (r*renderer) addYield(namestring, bindinginterface{}) {
funcs:= template.FuncMap{
"yield": func() (template.HTML, error) {
buf, err:=r.execute(name, binding)
// return safe html here since we are rendering our own templatereturntemplate.HTML(buf.String()), err
},
"current": func() (string, error) {
returnname, 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.
The text was updated successfully, but these errors were encountered:
Unless I'm missing something, the addYield method leaks memory.
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.
The text was updated successfully, but these errors were encountered: