Skip to content

Commit

Permalink
Fix memory leak in ruby_parser
Browse files Browse the repository at this point in the history
For example:

    10.times do
      100_000.times do
        eval("")
      end

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

Before:

    19872
    26480
    32848
    39504
    45904
    52672
    59200
    65760
    72128
    78496

After:

    17328
    20752
    23664
    28400
    30656
    34224
    37424
    40784
    43328
    46656
  • Loading branch information
peterzhu2118 committed Apr 29, 2024
1 parent d75bbba commit 95d036a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ruby_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ parser_free(void *ptr)
{
struct ruby_parser *parser = (struct ruby_parser*)ptr;
rb_ruby_parser_free(parser->parser_params);
xfree(parser);
}

static size_t
Expand Down

0 comments on commit 95d036a

Please sign in to comment.