e$B:XF#$H?=$7$^$9!#e(B
On Mon, 14 Apr 2008 20:45:26 +0900
“Akinori MUSHA” [email protected] wrote:
e$B!!1d$S1d$S$K$J$C$F$7$^$$$^$7$?$,!“$h$&$d$/e(B enumerator e$B4XO”!"e(B
Enumerable, Array e$B$N%P%C%/%]!<%H$,=*$o$j$^$7$?!#e(B
e$B!!L@F|$NM<J}$Ke(B preview1 e$B$r=P$7$^$9!#e(B
knue$B$5$s!"$*Hh$l$5$^$G$9!#e(B
e$B%H%i%C%+!<$N7+$jJV$7$K$J$C$F$7$^$$62=L$G$9$,!"$I$J$?$+e(B GC.stress
e$B$r%3%_%C%H$7$FD:$1e(B
e$B$^$;$s$G$7$g$&$+!#e(B
http://rubyforge.org/tracker/index.php?func=detail&aid=19000&group_id=426&atid=22040
e$B%9%/%j%W%H$r=q$$$F$$$k?M8~$1$H$$$&$h$j$b!"e(BCe$B$r=q$$$F$$$k?M8~$1$N5!G=$J$N$GM%@hEY$,e(B
e$B0lCJ2<$,$k$N$OG<F@$J$N$G$9$,!“Hs>o$K8D?ME*$JM}M3e(B(e$B3HD%%i%$%V%i%j$r=q$$$F$ke(B)e$B$+$ie(B
1.8e$B$K$bF~$C$F$$$k$H!”$H$F$b$&$l$7$$$G$9!#e(B
e$BFbMF$H$7$F$b!"e(Btrunke$B$+$i$[$\4]<L$7$G:Q$s$Ge(Bporte$B$i$7$$=$@5$b$J$/!"5;=QE*$J%j%9%/$bHf3SE*e(B
e$BDc$$$H9M$($^$9!#e(B
e$B%H%i%C%+!<$Ne(BWebe$B%Z!<%8$G$O!“$J$<$+9TKv$,@^$jJV$5$l$F$7$^$C$F%Q%C%A$,2u$l$F$$$ke(B
(e$B%a!<%k$Ne(B
notifier e$B$@$HBg>fIW$J$N$K!De(B)
e$B$N$G!”%a!<%kKvHx$K!"$=$l$rD{@5$7$F$+$D99?7$7$?%Q%C%A$re(B
e$B:F7G$7$^$9!#e(B
(…) e$B6=L#$H;~4V$,e(B
e$B$"$l$P$*4j$$$7$^$9!#e(B
e$B$H$$$&$3$H$G!“5$$,8~$$$?J}$,$b$7$$$i$C$7$c$C$?$i!”$h$m$7$/$*4j$$$7$^$9!#e(B
Index: signal.c
— signal.c (revision 16024)
+++ signal.c (working copy)
@@ -628,6 +628,8 @@
}
#endif
- extern int ruby_gc_stress;
- ruby_gc_stress = 0;
rb_bug(“Segmentation fault”);
}
#endif
Index: gc.c
===================================================================
— gc.c (revision 16024)
+++ gc.c (working copy)
@@ -76,6 +76,8 @@
static VALUE nomem_error;
static void garbage_collect();
+int ruby_gc_stress = 0;
+
void
rb_memerror()
{
@@ -89,6 +91,41 @@
rb_exc_raise(nomem_error);
}
+/*
-
-
- GC.stress => true or false
-
-
- returns current status of GC stress mode.
- */
-
+static VALUE
+gc_stress_get(self)
- VALUE self;
+{
- return ruby_gc_stress ? Qtrue : Qfalse;
+}
-
+/*
-
-
-
-
-
-
- When GC.stress = true, GC is invoked for all GC opportunity:
-
- all memory and object allocation.
-
-
- Since it makes Ruby very slow, it is only for debugging.
- */
-
+static VALUE
+gc_stress_set(self, bool)
- VALUE self, bool;
+{
- rb_secure(2);
- ruby_gc_stress = RTEST(bool);
- return bool;
+}
-
void *
ruby_xmalloc(size)
long size;
@@ -101,7 +138,7 @@
if (size == 0) size = 1;
malloc_increase += size;
- if (malloc_increase > malloc_limit) {
- if (ruby_gc_stress || malloc_increase > malloc_limit) {
garbage_collect();
}
RUBY_CRITICAL(mem = malloc(size));
@@ -141,6 +178,7 @@
if (!ptr) return xmalloc(size);
if (size == 0) size = 1;
malloc_increase += size;
- if (ruby_gc_stress) garbage_collect();
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
garbage_collect();
@@ -383,7 +421,7 @@
if (during_gc)
rb_bug(“object allocation during garbage collection phase”);
- if (!freelist) garbage_collect();
-
if (ruby_gc_stress || !freelist) garbage_collect();
obj = (VALUE)freelist;
freelist = freelist->as.free.next;
@@ -2037,6 +2075,8 @@
rb_define_singleton_method(rb_mGC, “start”, rb_gc_start, 0);
rb_define_singleton_method(rb_mGC, “enable”, rb_gc_enable, 0);
rb_define_singleton_method(rb_mGC, “disable”, rb_gc_disable, 0);
-
rb_define_singleton_method(rb_mGC, “stress”, gc_stress_get, 0);
-
rb_define_singleton_method(rb_mGC, “stress=”, gc_stress_set, 1);
rb_define_method(rb_mGC, “garbage_collect”, rb_gc_start, 0);
rb_mObSpace = rb_define_module(“ObjectSpace”);