Fix NoMemoryError problem with RBS tests + MSVC Ruby#363
Fix NoMemoryError problem with RBS tests + MSVC Ruby#363kou merged 1 commit intotest-unit:masterfrom
NoMemoryError problem with RBS tests + MSVC Ruby#363Conversation
6c84c6d to
a2e58ef
Compare
|
Hmm... This is needed for parallel execution... |
|
Thanks for your investigation. |
|
CI shows that passing the full test suite in
|
tikkss
left a comment
There was a problem hiding this comment.
How about this?
NoMemoryError has not occurred:
https://github.com/tikkss/test-unit/actions/runs/20531829390/job/58984227952
@options[:test_suite] is no longer used except to emit events for the top-level test suite.
The code that is called when an event is emitted is shown below.
In this code, the @tests instance variable is not used, so I decided it is safe to remove it.
@tests stores all tests, so it uses a large amount of memory.
test-unit/lib/test/unit/ui/console/testrunner.rb
Lines 495 to 518 in 5914658
test-unit/lib/test/unit/ui/console/testrunner.rb
Lines 486 to 493 in 5914658
| end | ||
| @options[:event_listener] = event_listener | ||
| @options[:test_suite] = @suite | ||
| @test_suite_runner_class.run_all_tests(result, @options) do |run_context| |
There was a problem hiding this comment.
| @test_suite_runner_class.run_all_tests(result, @options) do |run_context| | |
| event_listener = lambda do |channel, value| | |
| notify_listeners(channel, value) | |
| end | |
| @options[:event_listener] = event_listener | |
| # Large test suites (e.g. ruby/rbs) can cause | |
| # `NoMemoryError` only on MSVC Ruby. Clears a | |
| # needless instance variable to save memory | |
| # while keeping metadata for UI events. | |
| notifiable_suite = @suite.dup | |
| notifiable_suite.instance_variable_set(:@tests, []) | |
| @options[:test_suite] = notifiable_suite | |
| @test_suite_runner_class.run_all_tests(result, @options) do |run_context| |
a2e58ef to
4ec23a0
Compare
GitHub: Fix test-unitGH-358 I don't know why this fixes the `NoMemoryError` problem but this removes needless references. So GC will collect more objects. This change is included in 691a96e but this isn't needed for parallel test execution. Either way, we don't need this.
4ec23a0 to
b7c364a
Compare
|
Thanks for looking into this! I didn't notice that How about not changing |
tikkss
left a comment
There was a problem hiding this comment.
Sounds nice! NoMemoryError has not occurred:
https://github.com/tikkss/test-unit/actions/runs/20595170524/job/59148224585
How about this to a bit of DRY? This changes has not occurred too:
https://github.com/tikkss/test-unit/actions/runs/20595436660/job/59148989342
|
We can do it for DRY but I don't want to change
|
|
Thanks for your polite reply. I agreed. Let's merge this PR. |
|
Let's release a new version and try it in ruby/ruby. |
|
OK. I'll release a new version. And I'll create a PR in ruby/ruby. |
|
I've created a PR in ruby/ruby#15786 . |
GitHub: Fix GH-358
If we refer
@suitefrom@options,@suitemay not be GC-ed because@optionsmay be live longer than aTestRunner. For example,AutoRunner's@runner_optionsmay be@optionsandAutoRunnermay be live longer thanTestRunner.