[R] memory allocation glitches

Ben Bolker bolker at zoo.ufl.edu
Tue Aug 14 20:07:07 CEST 2007

(not sure whether this is better for R-devel or R-help ...)

 I am currently trying to debug someone else's package (they're
not available at the moment, and I would like it to work *now*),
which among other things allocates memory for a persistent
buffer that gets used by various functions.

 The first symptoms of a problem were that some things just
didn't work under Windows but were (apparently) fine on Linux.
I don't have all the development tools installed for Windows, so
I started messing around under Linux, adding Rprintf() statements
to the main code.

 Once I did that, strange pointer-error-like inconsistencies started
appearing -- e.g., the properties of some of the persistent variables
would change if I did debug(function).  I'm wondering if anyone
has any tips on how to tackle this -- figure out how to use valgrind?
Do straight source-level debugging (R -d gdb etc.) and look for
obvious problems?  The package uses malloc/realloc rather than
Calloc/Realloc -- does it make sense to go through the code
replacing these all and see if that fixes the problem?

   Ben Bolker

More information about the R-help mailing list