Re: [Rd] memory allocation questions

From: Duncan Murdoch <>
Date: Tue 14 Sep 2004 - 23:03:20 EST

On Tue, 14 Sep 2004 09:38:55 +1000, <> wrote :

>Dear R-devel
>This one seems a bit arcane for R-help. I very often use R to call routines written in Delphi (son of Pascal), doing "persistent" memory allocation within Delphi. That is, I start R and load the Delphi DLL; then I use .C to call a Delphi routine which allocates a piece of memory X and returns to R a pointer to X; then I do some more stuff in R; then I call another Delphi routine, passing it the pointer to X. Finally, I call another Delphi routine from R to free the memory at X.
>For years, I've used Delphi's own memory manager for this (the basic one, not SHAREMEM.DLL), but recently I've been wondering whether it would be better to use R's wrappers for "alloc" etc. instead. The Delphi routines seem generally to work fine, but my nagging concern [based on ignorance] is whether R's memory manager will somehow not realize that Delphi has already allocated the memory, and will overwrite it inadvertently. It's fairly easy to replace Delphi's manager with the R routines, following the instructions in section 5.1.2 of R-EXTS and the Delphi manual. So my first question is:
>should I bother using the R routines instead?

There is not much reason to need to use the R routines. The disadvantages of using Delphi allocation are:

The disadvantage of using the R routines Calloc etc. is that

Duncan Murdoch mailing list Received on Tue Sep 14 23:07:14 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:15 EST