错误 'Out of memory' 的原因是什么?
What is a reason of error 'Out of memory'?
我有一个矩阵B。
dim(B)
> 3025 3025
当我尝试使用此矩阵创建图形对象时收到错误消息:
library(igraph)
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
# Error in .Call("R_igraph_weighted_adjacency", adjmatrix,
# as.numeric(mode), :
# At vector.pmt:439 : cannot reserve space for vector, Out of memory
错误的原因是什么?这是 R 或我的 PC 的限制吗?
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Vista (build 6001) Service Pack 1
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_1.0.1
更新(@Gabor 评论后)。
我试图重现错误。我用过:
B <- matrix(runif(3025*3025, 0, 10), nc = 3025)
#Error: cannot allocate vector of size 69.8 Mb
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
object.size(B)
#73423056 bytes
object.size(g)
#395900 bytes
但错误是不同的。错误发生在从库 (igraph) 调用函数之前。然后我写了
B<-c()
>B
NULL
B <- matrix(runif(3025*3025, 0, 10), nc = 3025)
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
Error in .Call("R_igraph_weighted_adjacency", adjmatrix, as.numeric(mode), :
At vector.pmt:439 : cannot reserve space for vector, Out of memory
dim(B)
#[1] 3025 3025
object.size(B)
#73205112 bytes
object.size(g)
#395900 bytes
错误从未来自 library(igraph)
,它总是来自 graph.adjacency
。
igraph 针对稀疏图进行了优化,你的图是全图,所以这并不理想。
最重要的是,您需要更多内存。此图表需要大约 300 MB 内存,显然您没有。
如果创建失败,我不确定如何在 g
上调用 object.size
。
我有一个矩阵B。
dim(B)
> 3025 3025
当我尝试使用此矩阵创建图形对象时收到错误消息:
library(igraph)
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
# Error in .Call("R_igraph_weighted_adjacency", adjmatrix,
# as.numeric(mode), :
# At vector.pmt:439 : cannot reserve space for vector, Out of memory
错误的原因是什么?这是 R 或我的 PC 的限制吗?
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Vista (build 6001) Service Pack 1
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_1.0.1
更新(@Gabor 评论后)。 我试图重现错误。我用过:
B <- matrix(runif(3025*3025, 0, 10), nc = 3025)
#Error: cannot allocate vector of size 69.8 Mb
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
object.size(B)
#73423056 bytes
object.size(g)
#395900 bytes
但错误是不同的。错误发生在从库 (igraph) 调用函数之前。然后我写了
B<-c()
>B
NULL
B <- matrix(runif(3025*3025, 0, 10), nc = 3025)
g <- graph.adjacency(B, weighted=TRUE, mode="undirected", diag=FALSE)
Error in .Call("R_igraph_weighted_adjacency", adjmatrix, as.numeric(mode), :
At vector.pmt:439 : cannot reserve space for vector, Out of memory
dim(B)
#[1] 3025 3025
object.size(B)
#73205112 bytes
object.size(g)
#395900 bytes
错误从未来自
library(igraph)
,它总是来自graph.adjacency
。igraph 针对稀疏图进行了优化,你的图是全图,所以这并不理想。
最重要的是,您需要更多内存。此图表需要大约 300 MB 内存,显然您没有。
如果创建失败,我不确定如何在 g
上调用 object.size
。