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

Thomas Lumley tlumley at uw.edu
Mon Mar 5 20:34:33 CET 2012


On Tue, Mar 6, 2012 at 7:14 AM, jim holtman <jholtman at gmail.com> wrote:
> 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.
>

There is also the memory profiler, if your version of R is compiled to
include it.  That will show what functions are doing memory
allocation.

    -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list