Hi All, I've done some work recently making some of our image analysis library callable from R and Splus. Most of the C image functions use an abstract data type, and R only sees a pointer to this. All memory allocation is done by the library. This leads to some interesting problems. I'm interested in your views about possible solutions. 1) assignment. something like a<-b, where a and b are image pointers will only copy the pointer, not the image. We'd like to overload the <- operator to call the library copy routine. 2) garbage collection. It is now easy to lose track of memory, and this is likely to be significant because images are usually quite big. There is a delete function in the library, so it is possible to dispose of images manually, but an automated method would be nice. One option is to keep a global list of all pointers returned from C function calls, generate a list of all image class objects visible in R and compare the two. Any pointers not on the image class list can be disposed. Does anyone have any other ideas? All advice welcome. -- Richard Beare Richard.Beare@cmis.csiro.au -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Richard" == Richard Beare <Richard.Beare@cmis.csiro.au> writes:Richard> 2) garbage collection. It is now easy to lose track of Richard> memory, and this is likely to be significant because Richard> images are usually quite big. There is a delete function Richard> in the library, so it is possible to dispose of images Richard> manually, but an automated method would be nice. One Richard> option is to keep a global list of all pointers returned Richard> from C function calls, generate a list of all image class Richard> objects visible in R and compare the two. Any pointers Richard> not on the image class list can be disposed. Does anyone Richard> have any other ideas? I'd look to embed a JVM into R and use all the power of Java for image processing and garbage collection. I've done it with xlispstat but not with R. ________________________________________________________________ B. Narasimhan naras@stat.stanford.edu http://www-stat.stanford.edu/~naras -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> >>>>> "Richard" == Richard Beare <Richard.Beare@cmis.csiro.au> writes: > > Richard> 2) garbage collection. It is now easy to lose track of > Richard> memory, and this is likely to be significant because > Richard> images are usually quite big. There is a delete function > Richard> in the library, so it is possible to dispose of images > Richard> manually, but an automated method would be nice. One > Richard> option is to keep a global list of all pointers returned > Richard> from C function calls, generate a list of all image class > Richard> objects visible in R and compare the two. Any pointers > Richard> not on the image class list can be disposed. Does anyone > Richard> have any other ideas? > > I'd look to embed a JVM into R and use all the power of Java for image > processing and garbage collection. I've done it with xlispstat but not > with R. > ________________________________________________________________ > B. Narasimhan naras@stat.stanford.eduMy guess is that that would involve rewriting the existing library written in C. Similarly, embedding the JVM still requires some communication with the Java classes, etc. and conversion between the R and Java data structures. This is where the meat of the interface lies. However, on a more positive note, the embedding of the JVM into R and S4/Splus5, John Chambers and I have been playing with, is getting very close to being finished. I have been putting some of the final details to it over the weekend. So the dynamic communication with Java (i.e. dynamic method lookup and invocation) would not be that hard. D. -- _______________________________________________________________ Duncan Temple Lang duncan@research.bell-labs.com Bell Labs, Lucent Technologies office: (908)582-3217 700 Mountain Avenue, Room 2C-259 fax: (908)582-3340 Murray Hill, NJ 07974-2070 http://cm.bell-labs.com/stat/duncan Languages shape the way we think, and determine what we can think about -- Benjamin Whorf -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._