search for: r_clearexternalptr

Displaying 6 results from an estimated 6 matches for "r_clearexternalptr".

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 explicit closing function. I observed that - calling R_ClearExt...
2011 Sep 14
2
External pointers and an apparent memory leak
...that the R process continually creeps up in memory as seen by top while the usage as reported by gc() stays flat. I have isolated the C code: void h5R_allocate_finalizer(SEXP eptr) { Rprintf("Calling the 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...
2008 Jul 14
0
RODBC Seg Fault
...Close(conn) } [1] 1 RODB Connection 2 Details: case=nochange DSN=*** UID=*** PWD=*** [1] 2 RODB Connection 3 Details: case=nochange DSN=*** UID=*** PWD=*** [1] 3 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208248640 (LWP 14060)] 0x08059036 in R_ClearExternalPtr (s=0x0) at memory.c:2445 2445 memory.c: No such file or directory. in memory.c (gdb) bt #0 0x08059036 in R_ClearExternalPtr (s=0x0) at memory.c:2445 #1 0x006b17cb in inRODBCClose (thisHandle=0x8c1f358) at RODBC.c:1250 #2 0x006b190d in chanFinalizer (ptr=0x9100380) at RODBC.c:1271 #3...
2016 May 14
2
R external pointer and GPU memory leak problem
...pointer input is R external pointer, function will finalize the pointer? when it is not in use. */ static void _finalizer(SEXP ext) { if (!R_ExternalPtrAddr(ext)) return; ? ? ? ?double * ptr= (double *) R_ExternalPtrAddr(ext); Rprintf("finalizer invoked once \n"); cudacall(cudaFree(ptr)); R_ClearExternalPtr(ext); } My create function can run smoothly, but if I run the create function too many times, it shows out of memory for my GPU device, which clearly implies memory leak problem. Can anybody help? Help alot in advance!?
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
2010 Feb 18
3
R CMD check: OK in LINUX. Crashes in Windows!
Hi, I have followed the recommended steps for creating a package (rctest). As of now, my goal is simply to understand how various pieces fit together. The package includes: (1) C code with source in sub-directories, compiled to create a static library. (a) There is a single C-struct (dns) a simple 'matrix': {int m; int n; double *d;} (b) C code to create random matrix of a certain size.