css - Memory usage explodes when using CSSApply within function -
i observed weird behavior when using command cssapply
library css
inside function.
basically, each time call function, r uses additional 0.5mb of memory. since want use function extract data 20.000 webpages, r crashes because has memory problems.
here sample code reproduces problem:
library(css) f <- function() { url <- "http://www.kickstarter.com/projects/2049768676/schoolhaus-a4" page.o <- readlines(url) page <- htmlparse(page.o) name <- cssapply(page, "#name", csscharacter) return(name) } x <- character(200) (i in 1:length(x)) { x[i] <- f() print(i) flush.console() }
first thought using data.frame problem, figured out cssapply
problem. if comment out, memory usage stays more or less constant.
if has idea what's problem, appreciate help.
thanks much,
dainis
Comments
Post a Comment