path: root/test/objspace
AgeCommit message (Collapse)Author
2021-03-31Use EnvUtil.under_gc_stressNobuyoshi Nakada
2021-03-31skip marking for uninitialized imemo_env.Koichi Sasada
RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env objects and marking it will cause critical error. This patch skips marking on uninitialized imemo_env. See: Shortest repro-code is provided by mame-san. Notes: Merged:
2021-02-04objspace_dump.c: tag singleton classes and reference the superclassJean Boussier
Notes: Merged:
2021-02-01Implement NameError::message#clone for RactorNobuyoshi Nakada
Notes: Merged:
2020-10-03Fix ObjectSpace.dump(obj, output: :stdout)Kazuhiro NISHIYAMA
RDoc says `ObjectSpace.dump(obj, output: :stdout) # => nil`, but it returns STDOUT since fbba6bd4e3dff7a61965208fecae908f10c4edbe. I think it is unintentional change. Notes: Merged:
2020-09-25Return nil when argument to ObjectSpace.internal_class_of is T_IMEMOAlan Wu
The added test case crashes the interpreter because it makes ObjectSpace.internal_class_of return the second VALUE slot of an AST imemo object. The second VALUE slot of `struct rb_ast_struct` is not a VALUE and not a pointer to a Ruby object. Notes: Merged:
2020-09-09Optimize ObjectSpace.dump_allJean Boussier
The two main optimization are: - buffer writes for improved performance - avoid formatting functions when possible ``` | |compare-ruby|built-ruby| |:------------------|-----------:|---------:| |dump_all_string | 1.038| 195.925| | | -| 188.77x| |dump_all_file | 33.453| 139.645| | | -| 4.17x| |dump_all_dev_null | 44.030| 278.552| | | -| 6.33x| ``` Notes: Merged:
2020-09-09Add a :since option to dump_allJean Boussier
This is useful to see what a block of code allocated, e.g. ``` GC.start GC.disable ObjectSpace.trace_object_allocations do # run some code end gc_gen = GC.count allocations = ObjectSpace.dump_all(output: :file, since: gc_gen) GC.enable GC.start retentions = ObjectSpace.dump_all(output: :file, since: gc_gen) ``` Notes: Merged:
2020-08-19Fix ObjectSpace.trace_object_allocations_stop to not raise if the tracepoint ↵Jean Boussier
were not initialized Notes: Merged:
2020-08-18Reset object allocation trace informationAaron Patterson
Compaction makes collisions in the weak map more likely. For now, clear the tracing information before the test run so we get accurate results
2020-08-18Update references when tracing allocationsAaron Patterson
The allocation tracing code keeps essentially a weak reference to objects that have been allocated (storing the allocation information along with the weak ref). Compacting the heap would break references in this weak map, so the wrong values could be returned. This commit just updates the values in the weak ref in order to fix the allocation tracing book keeping Notes: Merged:
2020-08-18Disable debugging test.Koichi Sasada
``` 1) Failure: TestObjSpace#test_trace_object_allocations [/tmp/ruby/v3/src/trunk-gc_compact/test/objspace/test_objspace.rb:175]: <nil> expected but was <"/tmp/ruby/v3/src/trunk-gc_compact/test/objspace/test_objspace.rb">. ``` @tenderlove will re-enable it soon.
2020-08-17Fix method name escaping in ObjectSpace.dumpJohn Hawthorn
It's possible to define methods with any name, even if the parser doesn't support it and it can only be used with ex. send. This fixes an issue where invalid JSON was output from ObjectSpace.dump when a method name needed escaping. Notes: Merged:
2020-08-17Also escape DEL codeNobuyoshi Nakada
2020-08-17Fixed the radix for control charsNobuyoshi Nakada
2020-07-23Removed fragile tests in Nakada
2020-07-23Avoid allocating a string when dumping an anonymous module or classJean Boussier
Notes: Merged:
2019-06-30Suppress unused variable warningsNobuyoshi Nakada
2019-06-28Suppress unused variable warning with RUBYOPT=-wNobuyoshi Nakada
2019-06-28O_EXCL has no meaning for fdopenNobuyoshi Nakada
"exclusive access mode is not supported" exception has resulted in empty "rubyheap-*.json" files after test/objspace/test_objspace.rb.
2019-06-23Disable frozen-string-literal to disable deduplicationNobuyoshi Nakada
[Bug #14194]
2019-06-01Ignore warnings about ambiguous first argument of regexp with assert match.Hiroshi SHIBATA
2019-02-13fix imemo entry description.ko1
* ext/objspace/objspace.c (count_imemo_objects): `imemo_type_ids` should be match with `enum imemo_type` in internal.h and this patch fix mismatch. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-09ext/objspace/objspace_dump.c: print addresses consistentlynobu
The format addresses are printed in are different if you use `ObjectSpace.dump_all(output: :stdout)` vs. `ObjectSpace.dump_all(output: :string)` (or `ObjectSpace.dump`) due to differences in the underlying `vfprintf` implementation. Use `"%#"PRIxVALUE` to format `VALUE`. Co-authored-by: Ashe Connor <> git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-09Revert "ext/objspace/objspace_dump.c: print addresses consistently"naruse
This reverts commit r64970. Visual C++ 12.0 doesn't have PRIxPTR. Anyway we have our own vfprintf implementation BSD_vfprintf(). If you want to have portable vfprintf, replace it with BSD_vfprintf like vsnprintf or just use BSD_vfprintf. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08ext/objspace/objspace_dump.c: print addresses consistentlytenderlove
The format addresses are printed in are different if you use `ObjectSpace.dump_all(output: :stdout)` vs. `ObjectSpace.dump_all(output: :string)` (or `ObjectSpace.dump`) due to differences in the underlying `vfprintf` implementation. Use %"PRIxPTR" instead to be consistent across both. Co-authored-by: Ashe Connor <> git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10io.c: encoding of ARGF.inplace_modenobu
* io.c (argf_next_argv): encode inplace mode suffix to the path encoding. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17ext/objspace/objspace.c: remove unneeded code clones.mame
`setup_hash` have already performed nil check and empty check. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22fix mortal_dynamic_symbol countnobu
* test/objspace/test_objspace.rb (test_count_symbols): exclude a dynamic symbol which has been turned into immortal by define_method. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22try to fix symbol duplication.ko1
* test/objspace/test_objspace.rb (test_count_symbols): make more complex dynamic symbols to avoid conflict with other existing static symbols. Sometimes this test fails with "mortal_dynamic_symbol=>127". git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-31Add IMEMO type to heap dump output.tenderlove
IMEMO objects have many types. Without this change, we cannot see what types of IMEMO objects are being used when dumping the heap. Adding the type to the IMEMO object will allow us to gather statistics about IMEMO objects being used. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-04adjust indent [ci skip]nobu
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-03Add `full` option to `ObjectSpace.dump_all`tenderlove
The `full` option includes all slots (even `T_NONE`) in the JSON output. This is to help with debugging heap fragmentation. Here is an example usage: ```ruby'heap.json', 'w') do |f| ObjectSpace.dump_all(output: f, full: true) end ``` The `heap.json` file contains all slots, including empty slots. [Feature #13001] [ruby-core:78468] git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-16Use JSON lines format for full heap dumps.tenderlove
This commit changes full heap dumps back to using JSON lines format ( so that we can process very large heaps without loading the entire heap in to memory at once. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-12dump to stdoutnobu
* test/objspace/test_objspace.rb (test_dump_all): dump to stdout instead of a string, get rid of hung up. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-11ObjectSpace.dump_all: valid JSONnobu
* ext/objspace/objspace_dump.c: generate valid JSON for dump_all. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-19objspace_dump.c: special constnobu
* ext/objspace/objspace_dump.c: support special constant objects. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15fix typos [ci skip]kazu
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-14* test/objspace/test_objspace.rbnagachika
(test_trace_object_allocations_start_stop_clear): clear object allocation table first to get rid of erronous detection for obj3. [ruby-dev:49095] [Bug #11271] git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21* ext/objspace/objspace.c: add a new method ObjectSpace.count_symbols.ko1
[Feature #11158] * symbol.c (rb_sym_immortal_count): added to count immortal symbols. * symbol.h: ditto. * test/objspace/test_objspace.rb: add a test for this method. * NEWS: describe about this method. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12iseq.c (iseq_memsize): reimplement for wrappernormal
* iseq.c (iseq_memsize): reimplement for wrapper (param_keyword_size): extracted from iseq_memsize (iseqw_mark): new mark function (iseqw_data_type): new data type (iseqw_new): wrap as iseqw_data_type (iseqw_check): adjust for wrapper (Init_ISeq): remove iseqw_iseq_key initialization * test/objspace/test_objspace.rb: new test [ruby-core:70344] [Feature #11435] v2 changes: - added RUBY_TYPED_WB_PROTECTED and write barrier - account for rb_call_info_kw_arg_t entries git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-20* ext/objspace/objspace_dump.c(dump_object): Return empty JSON object whensorah
passed object is a special const, instead of SEGV. Based patch by Kohei Suzuki (eagletmt). [ruby-core:69692] [Bug #11291] * test/objspace/test_objspace.rb(test_dump_special_consts): Test for above fix. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-16* test/objspace/test_objspace.rb: relax pattern because uncollectibleko1
flag and marked flag can be false at major GC. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-28* ext/objspace/objspace.c: add two methods to debug internals.ko1
* ObjectSpace.internal_class_of: return RBASIC_CLASS(obj). * ObjectSpace.internal_super_of: return RCLASS_SUPER(cls). * NEWS: add information about both methods. * test/objspace/test_objspace.rb: add tests for both methods. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10* test/objspace/test_objspace.rb: remove debug prints.ko1
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10* ext/objspace/objspace.c: add ObjectSpace.count_imemo_objects methodko1
to count imemo objects for each type. * test/objspace/test_objspace.rb: add a test. * NEWS: describe about this addition. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-01test_objspace.rb: skip test_count_nodesnobu
* test/objspace/test_objspace.rb (test_count_nodes): NODEs are no longer used generally. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* test/objspace/test_objspace.rb: flag name was changedko1
(long_lived -> uncollectible). git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13test_objspace.rb: better assertionsnobu
* test/objspace/test_objspace.rb: use assertions for better failure messages. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e