diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-08 19:59:59 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-08 19:59:59 +0100 |
commit | d9126b1ad55267652511eab7f73f36f4a3b3ce8e (patch) | |
tree | 979d49bd05b22d4ca76423245d289c2859a272d8 /Userland | |
parent | 63e4b744ed176890465d5920b2421a48b193e978 (diff) | |
download | serenity-d9126b1ad55267652511eab7f73f36f4a3b3ce8e.zip |
js: Exercise the garbage collector a little bit
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/js.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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<JS::Program>(); auto block = make<JS::BlockStatement>(); @@ -55,5 +57,14 @@ int main() dbg() << "Interpreter returned " << result; printf("%s\n", result.to_string().characters()); + + interpreter.heap().allocate<JS::Object>(); + + 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; } |