Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!c34g2000yqi.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: MATLAB hangs with MEX code
Date: Mon, 10 Aug 2009 14:09:35 -0700 (PDT)
Organization: http://groups.google.com
Lines: 31
Message-ID: <342d4053-e7a6-443e-9ed9-a00f427ce172@c34g2000yqi.googlegroups.com>
References: <h5puv2$oa2$1@fred.mathworks.com>
NNTP-Posting-Host: 77.16.187.164
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1249938575 16696 127.0.0.1 (10 Aug 2009 21:09:35 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 10 Aug 2009 21:09:35 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: c34g2000yqi.googlegroups.com; posting-host=77.16.187.164; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:562236


On 10 Aug, 22:12, "Jose Antonio " <jurig...@gmail.com> wrote:
> Hi everybody
>
> I am trying to make a MEX function to split a double class grey scale image into 2^N areas, which I had already done successfully in MATLAB.
>
> The thing is that the compiled function works properly for N up to 8, and then MATLAB simply hangs, and I have to stop the process.
>
> I guess I might be again messing up with memory management, but I find no clue how to get things to work. Any help will be very welcome!

Memory managment is almost certainly not the main
problem.

When a program 'hangs' it is usally because some
control loop does not terminate; you forget to
increase a counter, you compare to the wrong number,
or something like that.

The way to handle these things is to work in a C
development environment, either on the command line
or an IDE. You develop and debug the C business code
in this environment, and then only use the MEX
routine as an interface to the C code.

You organize the C code as a number of small functions
with clear responsibilities. Test each function
independently, then assemble all of them to the
main working program.

The general principle is to divide and conquer.

Rune