I'm wondering where I can find the detailed descriptions on R memory management. Understanding this could help me understand the runtime of R program. For example, depending on how memory is allocated (either allocate a chuck of memory that is more than necessary for the current use, or allocate the memory that is just enough for the current use), the performance of the following program could be very different. Could somebody let me know some good references? unsorted_index=NULL for(i in 1:100) { unsorted_index=c(unsorted_index, i) } unsorted_index
For the case below, you don't need to know anything about how R manages memory, but you do need to understand basic concepts algorithmic complexity. You might find "The Algorithm Design Manual", http://www.amazon.com/dp/1848000693, a good start. Hadley On Thu, Dec 10, 2009 at 10:26 AM, Peng Yu <pengyu.ut at gmail.com> wrote:> I'm wondering where I can find the detailed descriptions on R memory > management. Understanding this could help me understand the runtime of > R program. For example, depending on how memory is allocated (either > allocate a chuck of memory that is more than necessary for the current > use, or allocate the memory that is just enough for the current use), > the performance of the following program could be very different. > Could somebody let me know some good references? > > unsorted_index=NULL > for(i in 1:100) { > ?unsorted_index=c(unsorted_index, i) > } > unsorted_index > > ______________________________________________ > R-help at 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. >-- http://had.co.nz/
Related... Rule of thumb: Pre-allocate your object of the *correct* data type, if you know the final dimensions. /Henrik On Thu, Dec 10, 2009 at 8:26 AM, Peng Yu <pengyu.ut at gmail.com> wrote:> I'm wondering where I can find the detailed descriptions on R memory > management. Understanding this could help me understand the runtime of > R program. For example, depending on how memory is allocated (either > allocate a chuck of memory that is more than necessary for the current > use, or allocate the memory that is just enough for the current use), > the performance of the following program could be very different. > Could somebody let me know some good references? > > unsorted_index=NULL > for(i in 1:100) { > ?unsorted_index=c(unsorted_index, i) > } > unsorted_index > > ______________________________________________ > R-help at 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. >