similar to: How to maintain memory in R extension

Displaying 20 results from an estimated 10000 matches similar to: "How to maintain memory in R extension"

2007 Feb 25
3
R/C++/memory leaks
Dear all, I have wrapped a C++ function in an R package. I allocate/deallocate memory using C++ 'new' and 'delete'. In order to allow user interrupts without memory leaks I've moved all the delete statements required after an interrupt to a separate C++ function freeMemory(), which is called using on.exit() just before the .C() call. I am concerned about the
2017 Mar 04
5
can we override "if" in R?
I'm just curious. Why making "if" generic is even more dangerous? Best, Da On Sat, Mar 4, 2017 at 1:22 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote: > `!` is a generic, `if` is not. You can define an `if` that is generic, > but this might be even more dangerous.... > > ? `if` <- function(a, b, c) UseMethod("if") > ? `if.default` <-
2017 Mar 05
3
can we override "if" in R?
On Sun, Mar 5, 2017 at 2:50 PM, Michael Lawrence <lawrence.michael at gene.com> wrote: > > > On Sat, Mar 4, 2017 at 12:36 PM, Da Zheng <zhengda1936 at gmail.com> wrote: >> >> In my case, I create a new type of matrices and override matrix >> operations in R for these matrices. >> My goal is to make the system as transparent as possible, which means
2017 Mar 04
2
can we override "if" in R?
In my case, I create a new type of matrices and override matrix operations in R for these matrices. My goal is to make the system as transparent as possible, which means my system should execute the existing R code without modification. The problem is that when data is in my own vectors or matrices, "if" or "while" can't access their values unless we explicitly convert them
2017 Mar 04
2
can we override "if" in R?
Thanks. Can I override it for a specific class? I can do that for operators such as "!". For example, "!.fm" works for objects of the class "fm". It seems I can't do the same for "if". Best, Da On Sat, Mar 4, 2017 at 12:41 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote: > You can. Perhaps needless to say, be careful with this. > > ?
2016 May 14
2
R external pointer and GPU memory leak problem
My question is based on a project I have partially done, but there is still something I'm not clear. My goal is to create a R package contains GPU functions (some are from Nividia cuda library, some are my self-defined CUDA functions) My design is quite different from current R's GPU package, I want to create a R object (external pointer) point to GPU address, and run my GPU function
2007 Aug 03
2
How to properly finalize external pointers?
Dear R .Call() insiders, Can someone enlighten me how to properly finalize external pointers in C code (R-2.5.1 win)? What is the relation between R_ClearExternalPtr and the finalizer set in R_RegisterCFinalizer? I succeeded registering a finalizer that works when an R object containing an external pointer is garbage collected. However, I have some difficulties figuring out how to do that in an
2016 Sep 15
1
Finalizer execution order question
Given an externalptr object 'pool' which protects an R object 'prot': # SEXP prot = (a dynamically updated list with handles) SEXP pool = R_MakeExternalPtr(p, R_NilValue, prot); R_RegisterCFinalizerEx(pool, fin_pool, TRUE); WRE explains that 'prot' remains in existence as long as 'pool' is around. Does this also mean 'prot' still exists when the
2013 Jul 25
1
[LLVMdev] Passing String to an external function in llvm
> OK - seems you might want to take a few steps back & understand how > C++ code is written/structured generally (and/or take a look at other > parts of the compiler). You'll need a header file with the declaration > of your function & you can include that header file in the > hashtable.cpp and testing.cpp - if that sentence doesn't make sense to > you yet, please
2017 Mar 06
1
can we override "if" in R?
I can't comment for Da, but one example where the ability to make 'if' generic would have been desirable: A couple of years ago I wrote S3 classes and methods for 1-byte integers and logicals stored as raw vectors, in order to handle massive amounts of genetic data (by the standards of the day). Everything worked pretty nicely, ie I could "methodize" just about everything I
2009 Feb 13
4
How to get first 10 items from hash in ruby?
Hello All, I am new to programming, i have little problem with hash. I want to retrieve first 10 items(key value pairs) from given hash{} hashTable = {"a" => 1, "b" => 5, "c" => 2, "d" => 6, "e" => 4, "f" => 7, "g" => 9, "h" => 5, "i" => 1, "j" => 8, "k"
2013 Jul 25
0
[LLVMdev] Passing String to an external function in llvm
On Thu, Jul 25, 2013 at 11:40 AM, Abhinash Jain <omnia at mailinator.com> wrote: > I have one file named hashtable.cpp whose link is > "http://pastebin.com/Cq2Qy50C" > > and one llvm pass named testing.cpp whose link is > "http://pastebin.com/E3RemxLF" > > Now on this testing.cpp pass I have computed the string named "expr" which I > want
2017 Jan 27
4
cross-platform portable code in CRAN Repository Policy
Hello, I'm trying to submit my package to CRAN. When I read the policy, it says: Package authors should make all reasonable efforts to provide cross-platform portable code. Packages will not normally be accepted that do not run on at least two of the major R platforms. What major R platforms does this policy refer to? Currently, my package runs in Ubuntu. If it works on both Ubuntu and
2013 Jul 25
2
[LLVMdev] Passing String to an external function in llvm
I have one file named hashtable.cpp whose link is "http://pastebin.com/Cq2Qy50C" and one llvm pass named testing.cpp whose link is "http://pastebin.com/E3RemxLF" Now on this testing.cpp pass I have computed the string named "expr" which I want to pass to the function named hashtable(string) in hashtable.cpp (on line 106 of testing.cpp) > looking at simple
2015 Nov 23
4
Custom C finalizers for .Call
WRE explains that R_alloc() can be used to allocate memory which automatically gets released by R at the end of a .C, .Call or .External, even in the case of an error or interruption. This is a really great feature to prevent memory leaks. I was wondering if there is a way to extend this mechanism to allow for automatically running UNPROTECT and custom finalizers at the end of a .Call as well.
2008 Apr 06
3
Multiset Permutations
Dear R users, I want to perform an exact permutation of multisets. I have looked at the coin package, but it doesn't seem to offer what I am looking for. I want to perform permutations (exact - without duplications) on multisets of scalars (e.g., the multiset 0,0,1,2,2). I want to output all the possible permutations into a data frame so that each multiset permutation occupies a row (or
2005 Dec 09
3
external pointers
I have some C data I want to pass back to R opaquely, and then back to C. I understand external pointers are the way to do so. I'm trying to find how they interact with garbage collection and object lifetime, and what I need to do so that the memory lives until the calling R process ends. Could anyone give me some pointers? I haven't found much documentation. An earlier message
2005 Jan 07
1
Destructor for S4 objects?
Hi, To write a "constructor" for an S4 object, you make an initialize method which will be called by new. But how would I make a "destructor" method to be called when the S4 object is garbage collected? I'm looking at reg.finalizer, but I'm not sure how to make that work for an S4 object. I want to write a destructor because my S4 object's initialize method
2017 Mar 04
2
can we override "if" in R?
Hello, I heard we can override almost everything in R. Is it possible to override "if" keyword in R to evaluate my own object instead of a logical value? Thanks, Da
2015 Dec 24
2
override pmin/pmax for my own matrix
Hello, I'm trying to override pmin and pmax for my own matrix. These two functions have ... as an argument. I tried to override them as follows: setMethod("pmax", class_name, function(x, ..., na.rm) { ... }) I use this way to override primitive functions such as min/max and it works fine. But it doesn't work for pmin and pmax. I guess because they are regular functions? How