"f1_soccer " <email@example.com> writes:
> I have a mex file,
> i deallocate memory for every thing i use, apart from a
> waveform which receive.I allocate space for it through
> mxCalloc and doesnot set if free.
> the matlab call is [a,b]=my_func(c,d)
> the mex file compiles smoothly and the first time i call the
> function in matlab, it works smoothly,
> but when i call the function again , the workspace goes
> blank, though if i type 'a' in command window, i can see the
> contents of a, and i can plot the contents of a too,
> now if i plot again, the matlab simply crashes (segment
> violation), it says to save ur work and restart matlab,
> as the code runs smoothly first time, i think its not a
> prob of mex file, but there is some problem with memory
Since the problem is precisely correlated with running your mex file,
the problem is likely in your MEX file.
Maybe the crash is when MATLAB goes to free the variable that you
returned. Maybe it's something different. Still, the symptom you
describe is typical for memory errors.
Show us how you allocate and fill your mex arrays. mxCalloc doesn't