Skip to content

Use free with ruby_dtoa #9151

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
Dec 7, 2023
Merged

Use free with ruby_dtoa #9151

merged 1 commit into from
Dec 7, 2023

Conversation

jhawthorn
Copy link
Member

In ae0ceaf ruby_dtoa was switched to use malloc instead of xmalloc, which means that consumers should be using free instead of xfree. Otherwise we will artificially shrink oldmalloc_increase_bytes.

I found this while investigating #9150

cc @nobu I'm not 100% sure this is the best approach or if we should #define MALLOC xmalloc in util.c ?

Before:

$ ./miniruby -e '10.times { 1000.times { 0.0.to_s }; GC.start(full_mark: false); puts GC.stat(:oldmalloc_increase_bytes) }'
10376
832
0
0
0
0
0
0
0
0

After:

$ ./miniruby -e '10.times { 1000.times { 0.0.to_s }; GC.start(full_mark: false); puts GC.stat(:oldmalloc_increase_bytes) }'
18376
8832
8832
8832
8832
8832
8832
8832
8832
8832

In ae0ceaf ruby_dtoa was switched to
use malloc instead of xmalloc, which means that consumers should be
using free instead of xfree. Otherwise we will artificially shrink
oldmalloc_increase_bytes.
@jhawthorn jhawthorn requested a review from nobu December 7, 2023 03:55
@jhawthorn jhawthorn merged commit 0c3593b into ruby:master Dec 7, 2023
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.

1 participant