Re: [Rd] Issue with memory deallocation/fragmentation on systems which use glibc
Dear R-devel mailing list and especially R-core, is there any chance to receive feedback on issue I described in previous emails? I would consider such behaviour as a bug. As a work-around I've created small "clean-up" function: malloc_trim_finalizer = function(e) { res = NULL if(R.version$os == "linux-gnu") { flog.debug("Calling malloc_trim(0L) to trigger glibc to release memory\n") res = malloc_trim(0L) } res } And at the end of each function which produce a lot of intermediate small objects I provide it to reg.finalizer(): some_function = function(...) { # do some useful work result = TRUE # register finalizer e = environment() reg.finalizer(e, malloc_trim_finalizer) return(result) } 2017-06-22 11:12 GMT+04:00 Dmitriy Selivanov : > A few additional details. According to Linux Programmer's Manual > >1. http://man7.org/linux/man-pages/man3/mallopt.3.html >2. http://man7.org/linux/man-pages/man3/malloc_trim.3.html > > And if I understood everything correctly `free` could trigger > `malloc_trim` based on value of several environment variables - > MALLOC_TOP_PAD_ and MALLOC_TRIM_THRESHOLD_. However setting them as low as > 1 or 0 doesn't have any effect (but as I wrote in previous email manual > call of `malloc_trim` helps to release memory). > -- Regards Dmitriy Selivanov [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] MASS:::dropterm.glm() and MASS:::addterm.glm() should use ... for extractAIC()
Here is a change required from MASS:::dropterm.glm() and MASS:::addterm.glm(). Thanks Marc The stepAIC() function from package MASS uses extractAIC() to get the AIC from a model. Several methods exist: extractAIC.glm() for example, some in MASS packages and some in stats package. The parameters for extractAIC() are: fit, scale, k = 2, ... The ... are not used in most of the extractAIC.xxx() methods, from example in stats:::extractAIC.glm() or MASS:::extractAIC.loglm() but its presence could be necessary if extractAIC() is changed to use for example to use AICc rather than AIC. Within stepAIC(), extractAIC() uses always the ... parameter. So all is ok for that. However, stepAIC() uses dropterm() or addterm(). Within MASS:::dropterm.glm() and MASS:::addterm.glm(), extractAIC() is also used but without the ... parameter. It prevents to use new version of extractAIC() that could use this parameter. The solution is simple: In MASS:::dropterm.glm(), line 60 and MASS:::addterm.glm(), line 84: aic <- aic + (extractAIC(object, k = k)[2L] - aic[1L]) must be changed to aic <- aic + (extractAIC(object, k = k, ...)[2L] - aic[1L]) Other dropterm.xxx() and addterm.xxx() do not suffer this problem. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel