From gb at tal.stat.umu.se  Thu Dec 30 17:20:10 2004
From: gb at tal.stat.umu.se (=?iso-8859-1?Q?G=F6ran_Brostr=F6m?=)
Date: Thu Dec 30 17:20:19 2004
Subject: [Rd] optim/vmmin and R_alloc
In-Reply-To: <Pine.A41.4.61b.0412300757350.11816@homer11.u.washington.edu>
References: <20041230155513.GA22178@tal.stat.umu.se>
	<Pine.A41.4.61b.0412300757350.11816@homer11.u.washington.edu>
Message-ID: <20041230162010.GA26602@tal.stat.umu.se>

On Thu, Dec 30, 2004 at 08:01:41AM -0800, Thomas Lumley wrote:
> On Thu, 30 Dec 2004, [iso-8859-1] G?ran Brostr?m wrote:
> >
> >However, and that is my question/suggestion: Why not use Calloc+Free
> >instead of R_alloc in vmmin (and maybe in other places)? I made the
> >changes in 'optim.c' in the functions 'vmmin' and 'Lmatrix'. Then I rebuilt
> >and reinstalled R-2.0.1. The result was great! My function ran very fast 
> >and
> >without any memory problems.
> >
> >So why not? Or will this change create other problems?
> 
> Memory will leak permanently if the functions are interrupted or an error 
> occurs.  This may be less serious now than it was in the past, since R can 
> be interrupted in fewer places.

Ok, I see. Is there any alternative solution, except for calling  .C  2000
times with only one call to vmmin each time?

Does this also mean that Calloc+Free should be avoided in contributed
packages? I use it exclusively in mine, and a quick search shows that it is
used in at least some recommended packages.

G?ran
-- 
 G?ran Brostr?m                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Ume? University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Ume?, Sweden             e-mail: gb@stat.umu.se


[Rd] optim/vmmin and R_alloc
=?iso-8859-1?Q?G=F6ran_Brostr=F6m?=