On Oct 31, 2012, at 3:13 AM, Adam Clark <atcl...@umn.edu> wrote:
> I'm running R 2.15.1x64, though the same problem persists for 2.13.0x32 and > 2.13.0x64. > > I am trying to run compiled C code using the .C convention. The > code compiles without problems, dynamically loads within the R > workspace with no problems, and even runs and gives correct results with > no problems. > > However, R will randomly crash within a few minutes of successfully using > the compiled function. > > For example, if I run my compiled function using: > dyn.load("mycfun.dll") > answer<-.C("mycfun", parameters...), I get a completely sensible > result that gets stored to "answer". > However, if I try to do too many things to "answer", the R exits > without warning. > I've tried dyn.unload in hopes that R would become stable afterwards, but > in this case using the function crashes R without fail. > > Usually, I can either plot, or view, or save "answer" to a file - but never > take more than a single action before R exits. This does not appear to > depend on how long R has been open. Initially, I thought it was a bug in > the "inline" function, but I'm finding the same problem now that I'm using > the dynamically loaded file directly. I'm used to R being insanely stable, > and am somewhat mystified by this whole problem. > > My next move is to learn the ".Call" convention, as I suspect that > my problem is related to my "C" function using memory that R doesn't > know is used. But - before I invest a while lot more time on this, I'd > like to know whether anybody things this is likely to solve the problem. > If not, I may just want to run my code entirely in C, and forget the > R problem. Hi Adam, Can you make a minimal reproducible example of your C sources available? I'm relatively certain that the problem is in the memory management therein, but I obviously can't say more without seeing the code. Michael > > -- > Adam Clark > University of Minnesota, EEB > 100 Ecology Building > 1987 Upper Buford Circle > St. Paul, MN 55108 > (857)-544-6782 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.