f



mex file, matlab crashes

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
management

Any one with any clue whats going on
0
im_aneeq (26)
10/18/2007 3:19:51 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
588 Views

Similar Articles

[PageSpeed] 36

"f1_soccer " <im_aneeq@yahoo.co.uk> 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
> management

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
sound correct.

-Peter
0
boettcher (2304)
10/18/2007 3:33:53 PM
Reply: