[Rd] Repeated use of dyn.load().

Rolf Turner r.turner at auckland.ac.nz
Fri Mar 2 01:43:47 CET 2018


I sent this enquiry to r-help and received several sympathetic replies, 
none of which were definitive.

It was kindly suggested to me that I might get better mileage out of 
r-devel, so I'm trying here.  I hope that this is not inappropriate.

My original enquiry to r-help:

==========================================================================
I am working with a function "foo" that explicitly dynamically loads a 
shared object library or "DLL", doing something like dyn.load("bar.so"). 
  This is a debugging exercise so I make changes to the underlying 
Fortran code (yes, I acknowledge that I am a dinosaur) remake the DLL 
"bar.so" and then run foo again.  This is all *without* quitting and 
restarting R.  (I'm going to have to do this a few brazillion times, and
I want the iterations to be as quick as possible.)

This seems to work --- i.e. foo seems to obtain the latest version of 
bar.so.  But have I just been lucky so far?  (I have not experimented 
heavily).

Am I running risks of leading myself down the garden path?  Are there 
Traps for Young (or even Old) Players lurking about?

I would appreciate Wise Counsel.
==========================================================================

One of the replies that I received from r-help indicated that it might 
be safer if I were to apply dyn.unload() on each iteration.  So I 
thought I might put in the line of code

     on.exit(dyn.unload("bar.so"))

immediately after my call to dyn.load().

Comments?

Another reply pointed out that "Writing R Extensions" indicates that 
there could be problems under Solaris, but does not single out any other 
OS for comment.  Might I infer that I am "safe" as long as I don't use 
Solaris?  (Which I certainly *won't* be doing.)

Thanks.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-devel mailing list