-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running XPtr finalizer on exit #655
Comments
You may need to resubscribe from the Berkeley address (or gmail or ...). Mailman uses strict string equality. |
The lifetime management is a delicate issue. In some (smaller, simpler) projects I just brought a general instance of what I needed up, and then down explicitly at the end. You may well deal with way more complicated setups here. But the |
I think ideally we would add a fourth argument to the So the example from xml2 is now: typedef Rcpp::XPtr<xmlDoc,Rcpp::PreserveStorage,xmlFreeDoc> XPtrDoc; And then to enable finalizing on exit one would do: typedef Rcpp::XPtr<xmlDoc,Rcpp::PreserveStorage,xmlFreeDoc, true> XPtrDoc; |
[I tried posting on the mailing list but having issues with my UCLA email...]
I am experiencing odd behavior in packages that use XPtr (V8, tesseract, xml2) which is caused by the fact that Rcpp does not run the finalizer when R quits. This can lead to corrupted connections, memory leaks, etc.
The problem is that Rcpp hardcodes the call to
R_RegisterCFinalizerEx
with onexit = FALSE which makes that R skips over the finalizer when exiting.Currently there is no way to fix this on the package side. Would there be a way to expose
onexit
as an option in Rcpp? Or better: make the defaultTRUE
(imo you should always cleanup after yourself). But I can live with opt-in if there is a good reason for not finalizing.The text was updated successfully, but these errors were encountered: