[R-SIG-Mac] memory leak in Ryacas?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Sep 24 00:12:03 CEST 2026


On 2026-09-23 10:51 a.m., Carl Witthoft wrote:
> Wondering if anyone else has seen this:
> I am running an iMac M4, Sequoia 15.7.9  and R 4.6.1 .
> 
> I notice that every call to yac_str   increases the memory usage as
> reported with the MacOS Activity Monitor.  Running gc() doesn't change
> anything.

What is yac_str?  It's not a base function, and you haven't shown us 
where it was defined in your code snippet.

Duncan Murdoch

> 
> The function I hacked together :
> 
> fibinet <- function(fidx = 5) {
> if(is.numeric(fidx)) {
>          fidx <- as.character(trunc(fidx))
>      }
> # loop over length(fidx)
> fout <- as.bigz(rep(0,length=length(fidx)))
>      for(jf in 1:length(fidx)) {
>          foo <- paste0('Simplify(1/k* (  ( (1 + k)/2)^', fidx[jf], '- ((1 -
> k)/2)^', fidx[jf], ' ) )')
>          bar <- yac_str(foo)
>          foob <- gsub('[/]([0-9]{1,})','/as.bigz("\\1")',bar)
>          foond <- unlist(strsplit(foob,'/'))
> 
>          foos <- unlist(strsplit(foond[1], '\\^'))
> # "fix" first element as it's not in the loop
>          foos[1] <- '(1'
> # need to fix the final numerator element's ')'
>          foos[length(foos)] <- gsub(')','',foos[length(foos)] )
>          for(jp in 2:(length(foos))) {
>              pxe <- regmatches(foos[jp],regexpr('^[0-9]{1,}',foos[jp]) )
>              # that gets the exponent as a string
>              fxe <- as.character(as.numeric(pxe)/2)
>              foos[jp] <- gsub(paste0('^',pxe),paste0('^',fxe), foos[jp])
>              # except that those coefficients in numerator exceed maxInt, so
> have to fix them
>          # one by one as well.  ewwww
>              pxc <- unlist(strsplit(foos[jp],'[+]'))
>              pxc[2] <- gsub('[*]k','',pxc[2])
>              fxc <- paste0('*k',pxc[1], '+as.bigz("', pxc[2],'")')
>              foos[jp] <- fxc
>              } #end jp loop
>      foof <- paste0(c(foos,')'),collapse='',sep='')
>      foof <- gsub('k','5',foof)
>      fout[jf] <- eval(parse(t= paste0(foof,'/',foond[2])))
>      }    #end jf loop
> return(invisible(list(idx=fidx,valx=fout)))
> }
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list