search for: e_ptr

Displaying 1 result from an estimated 1 matches for "e_ptr".

Did you mean: a_ptr
2011 Sep 14
2
External pointers and an apparent memory leak
...R_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 like this: v <- replicate(100000, { .Call("h5R_allocate", as.integer(1000000)) }) rm(v) gc() Then you can see the proble...