From simon.urbanek at r-project.org  Thu Jun 24 18:53:54 2010
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 24 Jun 2010 12:53:54 -0400
Subject: [Rd] How to debug: Cons memory exhausted
In-Reply-To: <AANLkTik4abuGDhcDZAU42IBOeLS06VjrvnfZiN5MDWb_@mail.gmail.com>
References: <AANLkTik4abuGDhcDZAU42IBOeLS06VjrvnfZiN5MDWb_@mail.gmail.com>
Message-ID: <E1191971-B855-4717-8CB3-C042DFA5E708@r-project.org>


On Jun 20, 2010, at 11:15 AM, Saptarshi Guha wrote:

> Hello,
> I get an error when binary structures from a pipe
> 
> 'Error: cons memory exhausted (limit reached?)' (but R does not crash)
> 
> This is probably due to some bug in my code, but occurs after reading
> about 85K pairs of RAWSXP objects (each < 20 bytes).
> 
> I do not have any explicit calls to malloc/calloc
> 

It has nothing to do with malloc/calloc - it means that the number of nodes (=R objects) has reached the limit. Normally the limit is soft so it will adjust up to SIZE_MAX (for all practical purposes unlimited on 64-bit machines). However, in low-memory conditions it may not be possible to allocate more heap space so that is more likely your limit.


> I'm going through my code and have inserted the (brute force) printf
> statements
> my question is: Does anybody have an advice on debugging this particular
> error?
> 

You can set a breakpoint on mem_err_cons. In general it means that you are simply running out of memory.

Cheers,
Simon



[Rd] How to debug: Cons memory exhausted
Simon Urbanek