From murdoch at stats.uwo.ca  Mon Sep 12 13:40:14 2005
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Mon, 12 Sep 2005 07:40:14 -0400
Subject: [Rd] A question on R memory management in .Fortran() calls
 under Windows
In-Reply-To: <3c12769c05091201305a31f10f@mail.gmail.com>
References: <3c12769c0509091004555400f@mail.gmail.com>	
	<4321CBB4.3090805@stats.uwo.ca>
	<3c12769c05091201305a31f10f@mail.gmail.com>
Message-ID: <4325691E.7020509@stats.uwo.ca>

Simone Giannerini wrote:
> Dear Duncan and Simon,
> 
> many thanks for your helpful reply.
> 
> 
>>Duncan Murdoch wrote:
>>It looks as though your Fortran compiler is allocating the new matrix on
>>the stack.  R doesn't give you a huge stack, and that's causing the
>>overflow.  When you get R to do the allocation, it does it on the heap,
>>which has no artificial limits.  Only a pointer to the object ends up on
>>the stack.
> 
>  
> yes, CVF allocates automatic objects on the stack and apparently there
> is no way of changing it. By the way, increasing the stack of the
> fortran process when linking does not solve the problem
> 
> 
>>I'd say your only reasonable workarounds are to tell your compiler to
>>use the heap for the local matrix allocation (if that's possible), or do
>>your allocations in R.
> 
> 
> I might follow the second way, in any case, I am considering switching
> to Linux, I have also  considered changing compiler under Win,  any
> suggestions on the choice would be welcomed.

I think it's far from the best optimizing compiler, but the Fortran that 
comes with MinGW (g77 currently in Windows) is the one used to build R, 
so it's the one that will is most likely to work with it without 
fiddling.  But I don't use Fortran, so I don't know what else is available.

Duncan Murdoch



[Rd] A question on R memory management in .Fortran() calls under Windows
Duncan Murdoch