[R] Re : stack overflow when loading workspace

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Sep 13 07:47:07 CEST 2009


There is a command-line flag for this:

tystie% R --help
...
   --max-ppsize=N        Set max size of protect stack to N

so you do not need to re-compile. It is not uncommon to need more 
space to load objects than to save them, and the need to raise this 
limit to re-load a worskpace has come up before on R-help (it is why 
there is a command-line flag).

The PP stack is not the only stack that can overflow; it is not even 
the commonest one.  So we could not have guessed without the error 
message, and if you raise this limit you may hit others.

I don't think 63000 objects is large, but 63000 named objects would
be.  Remember that each character string etc is an object (see
memory.profile() for a real count).


On Sat, 12 Sep 2009, Duncan Murdoch wrote:

> On 12/09/2009 5:04 PM, sebed1110-divers at yahoo.fr wrote:
>> Hi,
>> 
>> the error message is "Error: protect(): protection stack overflow"
>
> 63000 objects is far more than most people would use, so you may have hit an 
> internal limit.  The "protection stack" is used internally by R to 
> temporarily mark objects as "in use" even if they haven't been assigned 
> anywhere; overflows usually signal a bug in some code.  By default, it is 
> limited to 50000 entries, and it's very rare that any code would generate 
> more than that number of temporary objects. However, if you have 63000 
> objects, it's conceivable that they are all protected at some point during 
> loading.
>
> The easiest way to fix this may be not to produce so many objects.  I suspect 
> that they aren't all meaningful to you, you probably produced them 
> automatically.  So why not store them within a list, or some other structure? 
> That's the normal way to program in R.
>
> If you can't do that, you may be able to read your file by recompiling R with 
> a larger stack limit.  The line to change is in src/include/Defn.h around 
> line 214, currently
>
> #define	R_PPSSIZE	50000L
>
> Change that to a larger number and you might get lucky.
>
> Duncan Murdoch

>> 
>> Edwige.

>>> Dear all,
>>> 
>>> I can't load my workspace of 25Mo on R version 2.9.2, because of "
>> But I saved it normally (save.image()), and I didn't get any 
>> notification...
>>> Does anyone know what that can be due to? Is there any limitation of 
>>> number of objects (+/-63000)?
>> 
>> At least, the error message would be helpful.
>> 
>> Uwe Ligges
>> 
>>> Thanks
>>> 
>>> Edwige Polus.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list