Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak #5

Closed
tiredenzo opened this issue Oct 28, 2014 · 7 comments
Closed

Memory Leak #5

tiredenzo opened this issue Oct 28, 2014 · 7 comments

Comments

@tiredenzo
Copy link

Hello I experienced a memory leak which crashed my async jobs using this gem

This seriously leaks:

10000.times do (puts (Tilt::HandlebarsTemplate.new { "{{enzo}}" }).render({enzo: 'LOL'})) end

This does not Leak:

100000.times do (puts (Tilt::ERBTemplate.new { "<%= enzo %>" }).render(Hashie::Mash.new({enzo: 'LOL'}))) end

I will try to investigate it further today,
Thank you

@tiredenzo
Copy link
Author

Actually only

100000.times do Tilt::HandlebarsTemplate.new do '' end end

is enough to perform a leak

@jimothyGator
Copy link
Collaborator

Thanks for the test case. I've been swamped with the day job, but will try to take a look at this ASAP. If you've got a chance, you may want to see if you can create a memory leak with straight Handlebars.rb, not using tilt. That'll help isolate where the bug lies.

@tiredenzo
Copy link
Author

I'm still trying to isolate the bug on my free time...
if you have any suggestions on how I should proceed (gdb, ruby debug or else) you are welcomed
for now I think the leak is in

def prepare
  @context.partial_missing { |partial_name| load_partial partial_name }
end

@tiredenzo
Copy link
Author

This is weird because in my interpreter if I run

require 'handlebars'
10000.times do ::Handlebars::Context.new.partial_missing do |partial_name| '' end end

Handlebars.rb seems to work without leaking

but if i change in tilt-handlebars

def prepare
  @context = ::Handlebars::Context.new
  @context.partial_missing { '' }
end

and execute in my interpreter

require 'tilt/handlebars'
10000.times do Tilt::HandlebarsTemplate.new do '' end end

This still leaks; So i'll give a try between the interaction of tilt and tilt-handlebars as for me Handlebars.rb gem is not leaking

@jimothyGator
Copy link
Collaborator

Possibly related: cowboyd/handlebars.rb#38

@donbobka
Copy link

👍

@gi
Copy link
Owner

gi commented Feb 3, 2022

The Handlebars engine referenced in this issue has been replaced with https://github.com/gi/handlebars-ruby.

i'm going to close this issue because, after testing this with the new engine, there no longer seems to be an issue.

@gi gi closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants