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

Fix memory leak when exception is raised during JSON generation #574

Merged
merged 1 commit into from
Mar 22, 2024

Commits on Mar 21, 2024

  1. Fix memory leak when exception is raised during JSON generation

    If an exception is raised the FBuffer is leaked.
    
    For example, the following script leaks memory:
    
        o = Object.new
        def o.to_json(a) = raise
    
        10.times do
          100_000.times do
            begin
              JSON(o)
            rescue
            end
          end
    
          puts `ps -o rss= -p #{$$}`
        end
    
    Before:
    
        31824
        35696
        40240
        44304
        47424
        50944
        54000
        58384
        62416
        65296
    
    After:
    
        24416
        24640
        24640
        24736
        24736
        24736
        24736
        24736
        24736
        24736
    peterzhu2118 committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    44df509 View commit details
    Browse the repository at this point in the history