Dieter Menne
2008-Jan-18 14:28 UTC
[Rd] Memory loss in RODBC when reading DateTime values (no problem with integers)
This issue might be related to a similar one in http://article.gmane.org/gmane.comp.lang.r.devel/11452 ** Memory is not reclaimed when reading DateTime values, but works Ok when with integers. There is no memory loss when opening/closing of connection is done outside of the loop. However, opening itself cannot be the problem, since integers can be read without loss. I am aware that this is likely a Windows issue, not an R-problem, but reporting it may help others to track down more complex cases. Dieter # assumes a table db.mdb with ANumber (integer) and ADate(DateTime) exists library(RODBC) db = "db.mdb" # Generate Data tab = data.frame(ANumber=1:1000) tab$ADate= Sys.Date() channel = odbcConnectAccess(db) sqlQuery(channel, "DELETE * from tab") sqlSave(channel,tab,rownames=FALSE,append=TRUE) odbcClose(channel) # end of data generation for (i in 1:1000) { channel = odbcConnectAccess(db) # When reading a number, memory nicely zig-zags within safe gc limits # ret = sqlQuery(channel, "SELECT ANumber from tab") # Memory is lost ret = sqlQuery(channel, "SELECT ADate from tab") odbcClose(channel) cat(i,nrow(ret),memory.size(),"\n") } # end of example Package: RODBC Version: 1.2-2 Date: 2007-10-19 System: Vista Ultimate, German $platform [1] "i386-pc-mingw32" $arch [1] "i386" $os [1] "mingw32" $system [1] "i386, mingw32" $status [1] "" $major [1] "2" $minor [1] "6.1" $year [1] "2007" $month [1] "11" $day [1] "26" $`svn rev` [1] "43537" $language [1] "R" $version.string [1] "R version 2.6.1 (2007-11-26)">