On Jan 17, 2005, at 6:38 PM, dmitriy kuvshinov wrote:

But for the unknown reason the size of the memory used for this module, grows in memory of a computer at his cyclic use. What I incorrectly do?

you're not freeing everything you allocate with malloc().

XS-file (created by command "h2xs -A -n Smai"):
http://genphys.phys.msu.ru/~dmitriyk/Smai.xs

// ym-channel matrix ym = malloc(h * sizeof(*ym)); for (i=0; i<h; ++i){ ym[i] = malloc ( w * sizeof(**ym)); } // smai ym matrix sym = malloc(h * sizeof(*sym)); for (i=0; i<h; ++i){ sym[i] = malloc ( w * sizeof(**sym)); } [omit a bunch of processing] free(ym); free(sym);


you're allocating a pair of two-level data structures, but only freeing the outer layers, and leaking all the memory for each row.


add

     for (i = 0; i < h; h++) {
        free (ym[i]);
        free (sym[i]);
     }

before freeing ym and sym.


-- Eight, eight, eight, eight ounces to gooooo, you're gonna be sedated! -- Elysse, singing while feeding rice cereal formula to fussy infant Yvonne



Reply via email to