summaryrefslogtreecommitdiff
path: root/gc.rb
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-05-28 15:02:26 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2020-05-29 15:24:32 -0700
commit02b216e5a70235f42f537e895d6f1afd05d8916a (patch)
tree9e74ae2ba69e274a9fb1e468fa0c6687dced1616 /gc.rb
parentc1f6552b586d6ef11345166c4864b68e9d68504c (diff)
Combine sweeping and moving
This commit combines the sweep step with moving objects. With this commit, we can do: ```ruby GC.start(compact: true) ``` This code will do the following 3 steps: 1. Fully mark the heap 2. Sweep + Move objects 3. Update references By default, this will compact in order that heap pages are allocated. In other words, objects will be packed towards older heap pages (as opposed to heap pages with more pinned objects like `GC.compact` does).
Diffstat (limited to 'gc.rb')
-rw-r--r--gc.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/gc.rb b/gc.rb
index dd5781b603..23ed12ffdc 100644
--- a/gc.rb
+++ b/gc.rb
@@ -30,12 +30,12 @@ module GC
# Note: These keyword arguments are implementation and version dependent. They
# are not guaranteed to be future-compatible, and may be ignored if the
# underlying implementation does not support them.
- def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
+ def self.start full_mark: true, immediate_mark: true, immediate_sweep: true, compact: false
+ __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep, compact
end
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
+ __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
# call-seq:
@@ -188,7 +188,7 @@ end
module ObjectSpace
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
+ __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
module_function :garbage_collect