From d9126b1ad55267652511eab7f73f36f4a3b3ce8e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 8 Mar 2020 19:59:59 +0100 Subject: [PATCH] js: Exercise the garbage collector a little bit --- Userland/js.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Userland/js.cpp b/Userland/js.cpp index 876d1ae0f5..8e5249009a 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -33,6 +33,8 @@ int main() { + // function foo() { return 1 + 2; } + // foo(); auto program = make(); auto block = make(); @@ -55,5 +57,14 @@ int main() dbg() << "Interpreter returned " << result; printf("%s\n", result.to_string().characters()); + + interpreter.heap().allocate(); + + dbg() << "Collecting garbage..."; + interpreter.heap().collect_garbage(); + + interpreter.global_object().put("foo", JS::Value(123)); + dbg() << "Collecting garbage after overwriting global_object.foo..."; + interpreter.heap().collect_garbage(); return 0; }