gi / handlebars-ruby

A Ruby interface to the official JavaScript version of Handlebars.
MIT License
5 stars 0 forks source link

Memory: repeated engines/renders leak memory #14

Closed gi closed 2 years ago

gi commented 2 years ago

There seems to be a memory leak when creating engines or compiling templates.

The culprit seems to be the object finalizer: the creation of the lambda in the context of the instance is causing the Ruby VM to hold on to the engine's object.

From the documentation:

The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables.