[R] How to identify a matrix which causes memory limit?

jim holtman jholtman at gmail.com
Mon Mar 5 19:14:20 CET 2012


Learn some basic debugging for R.  There are several functions (debug,
browser, ...) that can help.  Put the following in your Startup
script:

options(error=utils::recover)

or at least execute it manually.  This will give you the trace of the
stack when the error happens and may help you identify the statement
that is causing the problem.  This may allow you to examine the
various objects you have at that point in time.

So there are ways that you can find out what the problem is, but you
will have to invest some time in learning how to debug your code.
There is also the 'debug' package which provides a nice way of tracing
execution in a function, but I think first follow the hints above to
trap when the error occurs so you can trace down what is causing it.

On Mon, Mar 5, 2012 at 12:22 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Mar 5, 2012, at 10:23 AM, huang jialin wrote:
>
>> Hello,
>>
>> I am running a simulation on an old computer with memory of 512M. I
>> constantly received a warning of "cannot allocate a vector of ...". How
>> can
>> I identify the matrix causing the problem? Is there any way to fix this
>> issue?
>
>
> ?object.size
>
>
>>
>> I would very appreciate your inputs. Thank you very much.
>>
>> Sincerely,
>> Jialin Huang
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> David Winsemius, MD
> West Hartford, CT
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list