Re: c mex file problem -- incorrect results
- From: Dan Hensley <somewhere@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 05 Jul 2007 23:59:37 -0500
On Thu, 05 Jul 2007 23:15:42 -0400, kendall wrote:
Dan Hensley wrote:
Thanks Dan. I tried memwatch, both when compiling the stand-along code
Sounds like a buffer overrun to me. The reason it works in standalone
mode is probably because you just call it once and then exit. In Matlab
the mex file stays resident in memory.
You might want to look at a tool such as memwatch (Google for it).
Dan
(exe) and when creating the mex file, but unfortunately memwatch didn't
detect a problem in either case.
Try a few more things just to understand the nature of the problem.
Does it always give the correct answer the first time you launch Matlab
and execute your mex file? How about if you run it in a loop, but do a
'clear <mexfilename>' after each time you invoke the function?
If it always gives the correct answer for the above cases, then look
closer for a memory overrun.
I ran into one recently where I was allocating an int a[4], but I was
using a[0] through a[5] in my code. It ran fine for a long time, but I
noticed after recompiling and adding some code to a different part of the
function that I got inconsistent results from a variable unrelated to my
array. The compiler must have rearranged it so the variable in question
was situated in memory right after the array.
If none of that helps, I'm out of ideas without seeing the source.
Dan
.
- References:
- c mex file problem -- incorrect results
- From: kendall
- Re: c mex file problem -- incorrect results
- From: Dan Hensley
- Re: c mex file problem -- incorrect results
- From: kendall
- c mex file problem -- incorrect results
- Prev by Date: Out of memory Exception in imview(infile)????
- Next by Date: chagne all font size in the figure
- Previous by thread: Re: c mex file problem -- incorrect results
- Next by thread: Re: c mex file problem -- incorrect results
- Index(es):
Relevant Pages
|