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:
Bob Nystrom
2015-10-24 17:56:27 +00:00
parent c9a7dba0c1
commit 498d1af8d0
4 changed files with 20 additions and 15 deletions
+3 -4
View File
@@ -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