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

unintentional object allocation #137

Closed
wants to merge 1 commit into from
Closed

unintentional object allocation #137

wants to merge 1 commit into from

Conversation

stereobooster
Copy link

ruby code/method/default-arguments.rb
Calculating -------------------------------------
constant as default argument
                         0.000  memsize (     0.000  retained)
                         0.000  objects (     0.000  retained)
                         0.000  strings (     0.000  retained)
new object as default argument
                       400.000k memsize (     0.000  retained)
                        10.000k objects (     0.000  retained)
                         0.000  strings (     0.000  retained)

Comparison:
constant as default argument  :          0 allocated
new object as default argument:     400000 allocated - Infx more

@benoittgt
Copy link

Related also : https://github.com/benoittgt/understand_ruby_memory#why-keywords-arguments-will-create-less-garbage-collected-objects-after-22-answered-

@stereobooster stereobooster deleted the bench-memory branch January 16, 2024 00:40
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.

None yet

2 participants