Magnus Torfason
2010-May-05 16:19 UTC
[R] Memory warning (Reached total allocation of ...) - but no error
Hi all, I'm getting the following warnings inside a loop: Warning messages: 1: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) 2: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) Usually, when I see these warnings, they are accompanied with an error message (Error: cannot allocate ...), but not in this case. I'm wondering how to react. I've tried adding a call to gc() inside the loop, i.e.: for (i in 1:1000) { calc.measures(g, 1, i) gc() } This gets rid of the warnings, but increases the running time by a factor of ten or so. So I'm thinking that maybe the warnings are simply telling me that calc.measures allocated so many temporary variables that garbage collection had to be triggered. But then I get a nagging feeling - why is R warning me that GC had to be triggered - isn't that the whole point of GC, that it gets triggered when memory is running out? I'd be grateful for advise on this: Should I just ignore these warnings as long as there are no errors, should I bite the bullet and call gc() manually, or is there a third way to deal with this? Best, Magnus ps. The reason the code is now in a loop is because a vectorized version gave me the same errors. So vectorization does not seem to be a usable fix here.
atan
2012-Jun-12 14:53 UTC
[R] Memory warning (Reached total allocation of ...) - but no error
Hi all I have searched for a solution to the following problem and even tried emailing the original poster, but have not had any luck in finding an answer. Magnus Torfason-2 wrote> > I'm getting the following warnings inside a loop: > > Warning messages: > 1: In calc.measures(g, 1, i) : > Reached total allocation of 1535Mb: see help(memory.size) > 2: In calc.measures(g, 1, i) : > Reached total allocation of 1535Mb: see help(memory.size) > > Usually, when I see these warnings, they are accompanied with an error > message (Error: cannot allocate ...), but not in this case. I'm wondering > how to react. > ... > So I'm thinking that maybe the warnings are simply telling me that > calc.measures allocated so many temporary variables that garbage > collection had to be triggered. But then I get a nagging feeling - why is > R warning me that GC had to be triggered - isn't that the whole point of > GC, that it gets triggered when memory is running out? > > I'd be grateful for advise on this: Should I just ignore these warnings as > long as there are no errors, should I bite the bullet and call gc() > manually, or is there a third way to deal with this? >I am in fact receiving a series of identical warnings inside a big function that I am running using Rx64 2.14.1 in Windows 7. The function runs to completion, and doesn't seem to be affected by the warnings. However, I am also weary as to why R is warning me about reaching my total memory allocation without throwing up an error and stopping the function, which has always happened in the past... Garbage collection is not a solution here as disused objects are cleared from memory before the evaluation within the function occurs at which the memory limit is likely being hit. Can anyone please offer an explanation as to why a warning would be reached but not an error? Even if the memory ceiling is hit during an internal evaluation or object assignment that the rest of the function does not "require" to run to completion, wouldn't an error still be called? Many thanks, Andrew -- View this message in context: http://r.789695.n4.nabble.com/Memory-warning-Reached-total-allocation-of-but-no-error-tp2131226p4633110.html Sent from the R help mailing list archive at Nabble.com.
Reasonably Related Threads
- Creating a list of empty lists
- Basic question: Reading in multiple choice question responses to a single column in data frame
- [Q] Get formal arguments of my implemented S4 method
- Recommended style with calculator and persistent data
- [Q] Get formal arguments of my implemented S4 method