public
Rubygem
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
adding a failing GC test
tenderlove (author)
Tue Jul 22 10:37:10 -0700 2008
commit  8e54e071f5094643e0622ffc9499401f727c23f6
tree    b1733f5d7290442b8b39cafe5e886b0e601cb84a
parent  a84310caa88e754d6b6e73cf9d310073892eb4d0
...
89
90
91
 
 
 
 
 
 
92
93
94
95
 
96
97
98
...
89
90
91
92
93
94
95
96
97
98
99
100
 
101
102
103
104
0
@@ -89,10 +89,16 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
0
 //// INFRASTRUCTURE BELOW HERE ////////////////////////////////////////////
0
 ///////////////////////////////////////////////////////////////////////////
0
 
0
+static void deallocate(JohnsonContext *context) {
0
+ JS_SetContextPrivate(context->js, 0);
0
+ JS_DestroyContext(context->js);
0
+ free(context);
0
+}
0
+
0
 static VALUE allocate(VALUE klass)
0
 {
0
   JohnsonContext* context = calloc(1, sizeof(JohnsonContext));
0
- return Data_Wrap_Struct(klass, 0, 0, context);
0
+ return Data_Wrap_Struct(klass, 0, deallocate, context);
0
 }
0
 
0
 void init_Johnson_SpiderMonkey_Context(VALUE spidermonkey)
...
18
19
20
21
 
22
23
24
...
18
19
20
 
21
22
23
24
0
@@ -18,7 +18,7 @@ module Johnson #:nodoc:
0
       
0
       # called from js_land_proxy.c:finalize
0
       def remove_gcthing(object_id)
0
- @gcthings.delete(object_id) if @gcthings
0
+ @gcthings.delete(object_id) if defined? @gcthings
0
       end
0
 
0
 
...
42
43
44
 
 
 
 
 
 
 
 
 
 
45
46
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
0
@@ -42,5 +42,15 @@ module Johnson
0
       assert_equal(10, break_times)
0
       assert_equal(2, @runtime['some_number'])
0
     end
0
+ def test_try_to_gc
0
+ 10.times {
0
+ thread = Thread.new do
0
+ rt = Johnson::Runtime.new
0
+ rt.evaluate('new Date()').to_s
0
+ end
0
+ thread.join
0
+ GC.start
0
+ }
0
+ end
0
   end
0
 end

Comments

    No one has commented yet.