Miller, Hans, et al,
I am forwarding you two patches that are memory leaks in pd. Pd vanilla is affected only by one of them, while pd-extended has both (second is magicGlass that Hans ported from pd-l2ork and that I just figured out a couple days ago). Since code bases are now fairly apart on the files involved, I am supplying the fix in this way in hope it is easier to understand this way.
1) The problem that affects all versions of pd can be tested using the bug report on the sourceforge is related to rtext freeing: http://sourceforge.net/tracker/?func=detail&aid=3605235&group_id=557... Following implementation fixes it both for GOP abstractions and individual objects:
In g_graph.c glist_delete() call:
at the beginning of the function + t_rtext *rt = NULL; + int late_rtext_free = 0;
further down instad of rtext_new(x, ob); + rt = glist_findrtext(x, ob); + if (rt) + late_rtext_free = 1;
at the end of the function + if (late_rtext_free) { + rtext_free(rt); + } } }
(late_rtext_free here is to provide more clarity to the process, it is obviously unnecessary since you could simply check for pointer value instead)
2) Magicglass fix (affects pd-extended only, memory leak due to improper freeing of magicGlass--to test simply check memory footprint as you keep recreating a GOP abstraction using a variant of the patch provided on the sourceforge): ========================= in g_magicglass.c (added unbind call):
void magicGlass_free(t_magicGlass *x) { //fprintf(stderr,"magicglass_free\n"); + magicGlass_unbind(x); x->x_dspOn = 0; clock_free(x->x_clearClock); clock_free(x->x_flashClock); }
in g_canvas.c canvas_free function: - if (x->gl_magic_glass) - magicGlass_free(x->gl_magic_glass); + if (x->gl_magic_glass) { + //magicGlass_free(x->gl_magic_glass); + pd_free(&x->gl_magic_glass->x_obj.te_g.g_pd); + } =========================
Best wishes,