I don't think sapply preallocates the entire matrix. It's building the matrix one row at a time, and when memory is full you get "Error: cannot allocate vector of size 7.6 Mb."
If you try to allocate the array with array(0,c(1E6,1E6)), you would get "Error: cannot allocate vector of size 7450.6 Gb." I'm a bit curious how much RAM Thyago has that he got your example to execute.
Yes, you are right. I forgot my original posting. The error was on some Mb where there are Gb of RAM available. So there must be some hidden allocation up to a point where the additional allocation of a few more Mb is not possible.
Interestingly, R 3.2.1 gives me additional warnings:
Error: cannot allocate vector of size 7.6 Mb
In addition: Warning messages:
1: In FUN(X[[i]], ...) :
Reached total allocation of 7944Mb: see help(memory.size)
2: In FUN(X[[i]], ...) :
Reached total allocation of 7944Mb: see help(memory.size)
3: In FUN(X[[i]], ...) :
Reached total allocation of 7944Mb: see help(memory.size)
4: In FUN(X[[i]], ...) :
Reached total allocation of 7944Mb: see help(memory.size)