feat: add System.gc() method and replace test's Api.gc() with it
Add a new `System.gc()` primitive that calls `wrenCollectGarbage` to allow scripts to trigger garbage collection. Document the method in the core System page. Remove the test-only `Api.gc()` foreign method and update the foreign_class test to use `System.gc()` instead.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
class Api {
|
||||
foreign static gc()
|
||||
foreign static finalized
|
||||
}
|
||||
|
||||
@@ -64,15 +63,15 @@ var resources = [
|
||||
Resource.new()
|
||||
]
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 0
|
||||
|
||||
resources.removeAt(-1)
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 1
|
||||
|
||||
resources.clear()
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 3
|
||||
|
||||
Reference in New Issue
Block a user