From: liamtabi@... Date: 2018-09-10T19:59:18+00:00 Subject: [ruby-core:88938] [Ruby trunk Bug#15088] Leaky behaviour when GC disabled Issue #15088 has been updated by william101 (William Tabi). Thank you @normalperson & @ko1 for taking a look and for the explanation here ���� ---------------------------------------- Bug #15088: Leaky behaviour when GC disabled https://bugs.ruby-lang.org/issues/15088#change-73972 * Author: william101 (William Tabi) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin17] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- Hello I've observed some leaky behaviour when creating dynamic Symbols ("string".to_sym) when GC is disabled. Creating a dynamic symbol after running `GC.disable` creates an extra string allocation that isn't garbage collected when GC is enabled later on in the code. Based on https://bugs.ruby-lang.org/issues/9634 and https://bugs.ruby-lang.org/issues/7791, I would have expected all the memory allocated by #to_sym to be GC'ed I can reproduce this using ~~~ ruby # frozen_string_literal: true require 'objspace' GC.start puts"Before - All: #{ObjectSpace.each_object.count}" puts"Before - Symbols: #{Symbol.all_symbols.size}" GC.start GC.disable 100_000.times do |i| "to_sym_#{i}".to_sym end GC.enable GC.start puts"After - All: #{ObjectSpace.each_object.count}" puts"After - Symbols: #{Symbol.all_symbols.size}" ~~~ This is the output: with latest master v2.6.0-dev ~~~ $ RBENV_VERSION=2.6.0-dev ruby -v /tmp/test.rb ruby 2.6.0dev (2018-09-07 trunk 64657) [x86_64-darwin17] Before - All: 10740 Before - Symbols: 3206 After - All: 110739 After - Symbols: 3206 ~~~ with ruby v2.2.2 ~~~ $ RBENV_VERSION=2.2.2 ruby -v /tmp/test.rb ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin17] Before - All: 6342 Before - Symbols: 2536 After - All: 106344 After - Symbols: 2536 ~~~ Would anyone know if this is expected behaviour or a bug? -- https://bugs.ruby-lang.org/ Unsubscribe: