Skip to content

[PRISM] Fix memory leak of ST table #9578

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

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

peterzhu2118
Copy link
Member

This commit fixes a memory leak in rb_translate_prism because the ST table is never freed. There are still more memory leaks which still need to be fixed.

For example:

10.times do
  100_000.times do
    RubyVM::InstructionSequence.compile_prism("")
  end

  puts `ps -o rss= -p #{$$}`
end

Before:

34544
57120
79360
102176
123712
146320
168192
190592
212192
234896

After:

18336
24592
31488
37648
44592
50944
57280
63632
69904
76160

This commit fixes a memory leak in rb_translate_prism because the ST
table is never freed. There are still more memory leaks which still need
to be fixed.

For example:

    10.times do
      100_000.times do
        RubyVM::InstructionSequence.compile_prism("")
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    34544
    57120
    79360
    102176
    123712
    146320
    168192
    190592
    212192
    234896

After:

    18336
    24592
    31488
    37648
    44592
    50944
    57280
    63632
    69904
    76160
@peterzhu2118 peterzhu2118 merged commit 947194a into ruby:master Jan 17, 2024
@peterzhu2118 peterzhu2118 deleted the prism-translate-mem-leak branch January 17, 2024 16:35
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

Successfully merging this pull request may close these issues.

2 participants