growing process size in simulation

Peter Dalgaard BSA
12 Oct 2002 12:04:23 +0200

Luke Tierney <> writes:

> It looks to me like something in deparse (which gets called in
> t.test.default) may be the culprit:
>    for(i in 1:100000) rval <- deparse("x")
> exhibits the same behavior.
> In running under gdb it looks like deparse("x") results in the call
> sequence
> deparse1WithCutoff->deparse2->deparse2buff->print2buff->R_AllocStringBuffer
> and malloc is called in R_AllocStringBuffer to create the buffer.  The
> allocation is stored into a local structure variable in
> deparse1WithCutoff and I think is not being free'd before
> deparse1WithCutoff exits.

Thanks for looking into this, Luke. Yes, I agree. Specifically, the
issue seems to be that we used to work off a static variable "buff"
and use realloc on that inside AllocBuffer if it was non-null. Now
we've put the variable inside a structure "buf->data" and still trying
to use the realloc'ing construct, but since "buf" (aka localData) is a
local variable, it gets NULL'ed every time deparse1WithCutoff() is
called ---> deparse1WithCutoff needs to clean up on the way out.

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (             FAX: (+45) 35327907
r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: