|
From: Martin R. <ru...@us...> - 2005-06-20 08:57:24
|
Update of /cvsroot/foo/foo/elkfoo/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26447/elkfoo/src Modified Files: bpf.m context.m defaults.m module.m modules.m snd.m task.m Log Message: fixed first series of refcounting related potential memory leaks. other yet to follow Index: context.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/context.m,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** context.m 28 Feb 2005 16:37:18 -0000 1.10 --- context.m 20 Jun 2005 08:57:13 -0000 1.11 *************** *** 152,155 **** --- 152,158 ---- Kill_Context(context); + /* rumori 2005-06-19: free objc garbage */ + [FOOGlobalsManager recycleAutoreleasePool]; + return True; } *************** *** 161,164 **** --- 164,170 ---- Terminate_Type(T_Context); + /* rumori 2005-06-19: free objc garbage */ + [FOOGlobalsManager recycleAutoreleasePool]; + return True; } *************** *** 194,197 **** --- 200,206 ---- GC_Unlink; + /* rumori 2005-06-19: free objc garbage */ + [FOOGlobalsManager recycleAutoreleasePool]; + return context; } Index: module.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/module.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** module.m 28 Feb 2005 16:37:18 -0000 1.7 --- module.m 20 Jun 2005 08:57:13 -0000 1.8 *************** *** 91,95 **** module = Alloc_Object(sizeof(struct S_Module), T_Module, 0); GC_Link(module); ! MODULE_T(module)->pointer = [[class alloc] init]; MODULE_T(module)->type = Null; MODULE_T(module)->context = Get_Context(); --- 91,96 ---- module = Alloc_Object(sizeof(struct S_Module), T_Module, 0); GC_Link(module); ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! MODULE_T(module)->pointer = AUTORELEASE([[class alloc] init]); MODULE_T(module)->type = Null; MODULE_T(module)->context = Get_Context(); Index: modules.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/modules.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** modules.m 28 Feb 2005 16:37:18 -0000 1.8 --- modules.m 20 Jun 2005 08:57:13 -0000 1.9 *************** *** 230,234 **** if (!Truep(Signal_Constantp(signal))) { ! return signal; } } --- 230,234 ---- if (!Truep(Signal_Constantp(signal))) { ! return signal; } } *************** *** 252,256 **** if (sum != 0) { ! input = [[[FOOMConstant alloc] init] setValue:sum]; [adder connectInput:count++ to:input]; } --- 252,257 ---- if (sum != 0) { ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! input = AUTORELEASE([[[FOOMConstant alloc] init] setValue:sum]); [adder connectInput:count++ to:input]; } *************** *** 493,497 **** if (quo != 1.) { ! input = [[[FOOMConstant alloc] init] setValue:quo]; [divider connectInput:count++ to:input]; } --- 494,499 ---- if (quo != 1.) { ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! input = AUTORELEASE([[[FOOMConstant alloc] init] setValue:quo]); [divider connectInput:count++ to:input]; } *************** *** 751,755 **** if (pro != 1.) { ! input = [[[FOOMConstant alloc] init] setValue:pro]; [multiplier connectInput:count++ to:input]; } --- 753,758 ---- if (pro != 1.) { ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! input = AUTORELEASE([[[FOOMConstant alloc] init] setValue:pro]); [multiplier connectInput:count++ to:input]; } *************** *** 1167,1171 **** if (dif != 0) { ! input = [[[FOOMConstant alloc] init] setValue:dif]; [subtracter connectInput:count++ to:input]; } --- 1170,1175 ---- if (dif != 0) { ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! input = AUTORELEASE([[[FOOMConstant alloc] init] setValue:dif]); [subtracter connectInput:count++ to:input]; } Index: task.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/task.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** task.m 28 Feb 2005 16:37:18 -0000 1.7 --- task.m 20 Jun 2005 08:57:13 -0000 1.8 *************** *** 182,185 **** --- 182,188 ---- // Alloca_End; + /* rumori 2005-06-19: free objc garbage */ + [FOOGlobalsManager recycleAutoreleasePool]; + return task; } *************** *** 370,373 **** --- 373,379 ---- // Alloca_End; + /* rumori 2005-06-19: free objc garbage */ + [FOOGlobalsManager recycleAutoreleasePool]; + return Make_Reduced_Flonum(done / TASK_T(task)->samplingrate); } Index: defaults.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/defaults.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** defaults.m 28 Feb 2005 16:37:18 -0000 1.4 --- defaults.m 20 Jun 2005 08:57:13 -0000 1.5 *************** *** 91,94 **** --- 91,103 ---- + static SchemeObject + P_Autorelease_Pool () + { + [FOOGlobalsManager recycleAutoreleasePool]; + + return True; + } + + #define DP Define_Primitive *************** *** 103,106 **** --- 112,118 ---- DP(P_Set_Default_Bsize, "foo:set-default-bsize!", 1, 1, EVAL); + // experimental + DP(P_Autorelease_Pool, "foo:autorelease-pool", 0, 0, EVAL); + P_Provide(Intern("defaults")); } Index: bpf.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/bpf.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** bpf.m 28 Feb 2005 16:37:18 -0000 1.8 --- bpf.m 20 Jun 2005 08:57:13 -0000 1.9 *************** *** 86,90 **** } GC_Link(points); ! bpf = A_Make_Bpf([[FOOBreakpointFunction alloc] init]); GC_Unlink; zone = [IdOf(bpf) zone]; --- 86,91 ---- } GC_Link(points); ! /* rumori 2005-06-19: avoid memleak, therefore AUTORELEASE */ ! bpf = A_Make_Bpf(AUTORELEASE([[FOOBreakpointFunction alloc] init])); GC_Unlink; zone = [IdOf(bpf) zone]; Index: snd.m =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/src/snd.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** snd.m 28 Feb 2005 16:37:18 -0000 1.6 --- snd.m 20 Jun 2005 08:57:13 -0000 1.7 *************** *** 108,112 **** snd = Alloc_Object(sizeof(struct S_Snd), T_Snd, 0); ! SND_T(snd)->pointer = [[class alloc] init]; /* * for GC: as long as a snd exists it's context will also --- 108,118 ---- snd = Alloc_Object(sizeof(struct S_Snd), T_Snd, 0); ! ! /* rumori 2005-06-19: we have to take of the refcount of the object: ! * context takes care of deletion. therefore added AUTORELEASE. ! * otherwise we would have to release the object on GC as well in ! * finalizer (would be cleaner, but much more work) ! */ ! SND_T(snd)->pointer = AUTORELEASE([[class alloc] init]); /* * for GC: as long as a snd exists it's context will also |