Hi All, 

 

There is something I don't quite understand about R memory management. 

 

I have the following function

 

function (AdGroupId) 

{

  print(memory.size())

  channel <- odbcConnect("RDsn", uid = "xxxx", case = "tolower", pwd =
"xxxxxx")

  Tree1 <- sqlQuery(channel, "exec SelectAdgroups 111120,0", as.is =
c(FALSE, FALSE, FALSE, FALSE, TRUE))

  Tree2 <- sqlQuery(channel, "exec SelectAdgroups 200337,0", as.is =
c(FALSE, FALSE, FALSE, FALSE, TRUE))

  gc()

  print(memory.size())

  odbcClose(channel)

  rm(channel);rm(Tree1);rm(Tree2);

  gc()

  print(memory.size())

  return(NULL)

}

 

I ran the function twice and I got the following results:

 

> prop(1000)

[1] 11.0589

[1] 15.97034

[1] 13.43737

NULL

> prop(1000)

[1] 13.43737

[1] 17.97294

[1] 17.42295

NULL

 

As you can see the size of the memory is being increased with each call to
the function. When I call the function using apply the memory usage keeps
growing until I get out of memory error.

 

It was tested on 4 different environments:

R:  2.4.0  and 2.6.1

OS: WinXp 64/32

 

Any ideas? 

 

Thanks,

Yoni.

 

 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to