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 with BigDecimal::EXCEPTION_OVERFLOW #290

Closed
MaxLap opened this issue Feb 29, 2024 · 2 comments · Fixed by #294
Closed

Memory leak with BigDecimal::EXCEPTION_OVERFLOW #290

MaxLap opened this issue Feb 29, 2024 · 2 comments · Fixed by #294
Labels

Comments

@MaxLap
Copy link

MaxLap commented Feb 29, 2024

Hello, the following causes a memory leak.

I left a commented line, both trigger an memory leak. I assume it's the same bug

require 'bigdecimal'

BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true)

10.times do |j|
  100000.times do |i|
    begin
      BigDecimal("1E11111111111111111111")
      #BigDecimal("1E1000000000000000000")**10 # Also leaks
    rescue
    end
  end

  GC.start
  puts `ps -o rss= -p #{$$}`.to_i
end
$ ruby local.rb
28652
34988
41060
47396
53732
59804
66140
72476
78548
84884

Happens in 3.2.3, 3.3.0, 3.3-head, ruby-head (of a few days ago, which use big-decimal 3.1.6).

@mrkn
Copy link
Member

mrkn commented May 4, 2024

@MaxLap Thank you for your report. I'm fixing this bug in #294.

@mrkn mrkn closed this as completed in #294 May 6, 2024
@mrkn
Copy link
Member

mrkn commented May 7, 2024

@MaxLap I've released v3.1.8. It should fix this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants