Displaying 13 results from an estimated 13 matches for "r_registercfinalizerex".
Did you mean:
r_registercfinalizer
2013 May 24
1
Problem with Rboolean in c++ code
I am trying to use R_RegisterCFinalizerEx to ensure some c++ object is
properly deleted after use. However, I run into some problems when
trying to pass in the third argument which is an Rboolean. The line
'R_RegisterCFinalizerEx(p, finalizer, TRUE);' generates the following
error when trying to compile using R CMD SHLIB:...
2011 Sep 14
2
External pointers and an apparent memory leak
...finalizer\n");
void* vector = R_ExternalPtrAddr(eptr);
free(vector);
R_ClearExternalPtr(eptr);
}
SEXP h5R_allocate(SEXP size) {
int i = INTEGER(size)[0];
char* vector = (char*) malloc(i*sizeof(char));
SEXP e_ptr = R_MakeExternalPtr(vector, R_NilValue, R_NilValue);
R_RegisterCFinalizerEx(e_ptr, h5R_allocate_finalizer, TRUE);
return e_ptr;
}
If I run an R program like this:
v <- replicate(100000, {
.Call("h5R_allocate", as.integer(1000000))
})
rm(v)
gc()
Then you can see the problem (top reports that R still has a bunch of memory, but R doesn't think it do...
2005 Oct 24
2
R_MakeExternalPtr
Hi,
I'm using R_MakeExternalPtr() to store handles to (COM) objects in a SEXP.
The code basically is
sexp = R_MakeExternalPtr(handle,R_NilValue,R_NilValue);
R_RegisterCFinalizerEx(...);
After creating the sexp, LENGTH(sexp) returns some quite large integer
value. It seems like an "unitialized" value.
Can I safely assume, that an SEXP of type EXTPTRSXP can only contain a
single pointer value and never represent a vector (an array) of pointers? Or
should I maybe ex...
2016 May 14
2
R external pointer and GPU memory leak problem
...? ? ? ?double * temp;?
? ? ? ?temp = REAL(input);
double *x; ? ? ? ? ? ? ? ##here is the step which causes the memory leak
cudacall(cudaMalloc((void**)&x, *lenth * sizeof(double)));
//protect the R external pointer from finalizer
SEXP ext = PROTECT(R_MakeExternalPtr(x, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ext, _finalizer, TRUE);
?
//copying CPU to GPU
cublascall(cublasSetVector(*lenth, sizeof(double), temp, 1,?
R_ExternalPtrAddr(ext), 1)); ? ?
? ? ? ?UNPROTECT(2);
return ext;
}
here is my finalized for my create function,
/*
define finalizer for R external pointer
input is R external pointer, fu...
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 finalizer of
'pool' gets executed?
Long story: I am running into an issue with the next generation of the
curl package...
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
2020 Apr 03
0
The finalizer of the externalPtr does not work when closing R?
See R_RegisterCFinalizerEx() and set onexit to nonzero. Here:
https://github.com/wch/r-source/blob/9353ddfa8d30069ad8975e0364307d710f2488d5/src/include/Rinternals.h#L1279-L1280
Gabor
On Fri, Apr 3, 2020 at 1:56 PM Wang Jiefei <szwjf08 at gmail.com> wrote:
>
> Hi all,
>
> I found that the finalizer of the...
2006 Apr 10
2
Run package code on R shutdown?
I'm sure I've seen this discussed before, but haven't been able to find
it. I'd like some package code to be run when R is shut down
(approximately when a user's .Last function would be run), to clean up
properly. What is the best way to do this?
Duncan Murdoch
2002 Nov 09
1
Calling function with proto in Rinternals.h
(Tried this query on r-help with no luck, maybe someone here can help?)
I would like to call the 'RFinalizerEx' function that appears in
Rinternals.h using ".Call". It worked for me in the past, but now I get
an error message something like: 'call function name not in call table'.
I'm using the 1.6.1 rpm from CRAN. Anyone know what's going on? Thanks.
Tim
--
2020 Apr 03
4
The finalizer of the externalPtr does not work when closing R?
Hi all,
I found that the finalizer of the externalPtr is not called when R is
quitting. However, manually calling GC() works fine. This behavior is
observed on devel R 2020-04-02 r78142 on Win and R 3.6.3 on Ubuntu. I make
a reproducible package here: https://github.com/Jiefei-Wang/example
Here is the detail of how to reproduce the problem, I create a temporary
file in the package root path and
2024 Apr 25
1
Big speedup in install.packages() by re-using connections
I'd like to raise this again now that 4.4 is out.
Below is a more complete patch which includes a function to properly
cleanup libcurl when R quits. Implementing this is a little tricky
because libcurl is a separate "module" in R, perhaps there is a better
way, but this works:
view: https://github.com/r-devel/r-svn/pull/166/files
patch:
2009 Sep 04
3
asking for suggestions: interface for a C++ class
Dear All,
I would like to have an advice for designing an R library, and thought
that R-devel may be the best place to ask given so many people who are
highly expert in R are around.
We are at an early stage of designing an R library, which is
effectively an interface to a C++ library providing fast access to
large matrices stored on HDD as binary files. The core of the C++
library is
2011 Jun 04
2
Interfacing a C++ class
Hello
Apologies for cross-posting, the discussion should (if) go to R-devel, but I also want to reach the rcpp-devel people.
My C++ class FOO is a module available through Rcpp, and it works fine and is -- so far -- bug free. With trying to further develop my R package, I thought it was a good idea to interface my C++ workhorse FOO with an S4 class Foo. After some long and not always insightful