Actions
Misc #19870
closedWhy is a long-run thread allocated more memory than a short-run one?
Status:
Feedback
Assignee:
-
Description
I want to write multithreading programing in Ruby but I found the following memory consumptions.
$ irb
irb(main):001> require 'objspace'
=> true
irb(main):002> t1 = Thread.new {}
=> #<Thread:0x00007f9237a74b28 (irb):2 run>
irb(main):003> t2 = Thread.new { sleep 6000 }
=> #<Thread:0x00007f9237b4f1d8 (irb):3 run>
irb(main):004> t3 = Thread.new { loop { sleep 5 } }
=> #<Thread:0x00007f9237b6d840 (irb):4 run>
irb(main):005> ObjectSpace.memsize_of(t1)
=> 360
irb(main):006> ObjectSpace.memsize_of(t2)
=> 1048936
irb(main):007> ObjectSpace.memsize_of(t3)
=> 1048936
irb(main):008>
Is the above behavior legitimate?
Actions
Like0
Like1