2017-09-26 66 views
1
> sessionInfo() 
R version 3.4.0 (2017-04-21) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows >= 8 x64 (build 9200) 

在一個32G系統中,我創建距離矩陣,當得到這個錯誤:爲什麼R報告使用Windows的內存比自己多得多?

df <- remove_duplicates_quanteda(dfm, df) 
Error: cannot allocate vector of size 1.3 Gb 

尋找我的環境裏面,有一點值得關注的理由:

print(object.size(x = lapply(ls(), get)), units = "Mb") 
96.5 Mb 

然而,Windows報告以下數字: 這種差異的原因是什麼?有沒有辦法找出答案?

+0

難道是要分配矩陣每列/行(矢量)約1.3GB?你計算距離矩陣的數量是多少? – AaronP

+0

使用'pryr :: object_size()'報告的類似練習是什麼? – hrbrmstr

+0

'錯誤:無法分配大小爲1.3 Gb的向量'意味着R一直在愉快地分配內存,直到沒有更多可用內存爲止。它報告下一次分配需要多少內存(在你調用的函數內)。即使你有更多的內存1.3 GB,它可能不足以進行下一次分配。距離矩陣可能很大。根據您的全球環境,您無法判斷是否有理由擔心。你必須考慮你想要做的操作的內存需求。 – Roland

回答

0

哈德利把它很簡單,在先進的R:

This number won’t agree with the amount of memory reported by your operating system for a number of reasons:

  1. It only includes objects created by R, not the R interpreter itself.

  2. Both R and the operating system are lazy: they won’t reclaim memory until it’s actually needed. R might be holding on to memory because the OS hasn’t yet asked for it back.

  3. R counts the memory occupied by objects but there may be gaps due to deleted objects. This problem is known as memory fragmentation.

欲瞭解更多信息,請參閱節約Memory

+0

感謝您的參考。但這不僅僅是報告和回收分配的內存,因爲它實際上具有不能分配1.3G矢量的結果。出於各種原因(包括虛榮心),我無意關閉Visual Studio/reboot。 – user1603472

相關問題