[Rd] invalid regular expression after many grep's (PR#691)
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Wed, 25 Oct 2000 15:25:43 +0200 (MET DST)
Turns out that someone forgot to call regfree in the internal code for
strsplit and also forgot to free pt there. After I found those two,
there is no more memory build up in your example, although I did
not have the patience for 200k calls. (After 1000 there had been
appreciable buildup, and there was exactly none after the fixes.)
The memory management on the next version of R for Windows will be
radically different, and you will be able to set a limit on
total malloc-ed space, for example. (R-core: this is an
example why one might want to.)
> From: "Joachim Utans" <jutans@utans.u-net.com>
> To: Prof Brian Ripley <ripley@stats.ox.ac.uk>
> Date: Thu, 12 Oct 2000 20:32:40 +0100
> Subject: Re: [Rd] invalid regular expression after many grep's (PR#691)
> X-Keywords:
>
>
> While trying to create a simple test it turns out that the real
> culprit appears to be strsplit. What I am doing is to parse
> many lengthy text-files, perform some substitutions and write out
> the results (I probably should use Perl but this also does other R
> calculations). Some of the actions performed call strsplit but
> the error message always came from grep, but they both call the
> underlying regexp functions I assume.
>
> Below is an example that fails on my machine after around 200k
> iterations (this of course is an inappropriate use of strsplit
> as the loop is not necessary).
> Machine is 2*733 PIII, 256Mb RAM, starting R with --vanilla,
> and R_VSIZE=160M, R_NSIZE=1500k.
>
>
> bugtest <- function(n=500, file="d:/rw/faq") {
> for (j in 1:n) {
> tmp <- scan(file, "", sep="\n")
> for (i in 1:length(tmp)) {
> x <- strsplit(tmp[i], " ")[[1]]
> }
> }
> }
>
> After exiting with q(), R then crashes (try to access memory at 0x0000)
> N.B. strsplit(.,NULL) does not crash, no regexpr involved(?)
>
> Come to think of it, when R does crash for me I think a large fraction
> of crashes occurs in functions that in some way call strsplit, though
> I have not kept track of this.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._