Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpretation of gc() result in R

Tags:

How to interpret result of gc() :

Garbage collection 9 = 1+0+8 (level 2) ... 
10.7 Mbytes of cons cells used (49%)
40.6 Mbytes of vectors used (72%)
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells  198838 10.7     407500 21.8   350000 18.7
Vcells 5311050 40.6    7421749 56.7  5311504 40.6

and how can we see if any garbage have been collected ?

like image 960
Qbik Avatar asked Jan 26 '16 23:01

Qbik


People also ask

What does GC () do in R?

R uses an alternative approach: garbage collection (or GC for short). GC automatically releases memory when an object is no longer used. It does this by tracking how many names point to each object, and when there are no names pointing to an object, it deletes that object.

What is Gc trigger in R?

gc trigger column reports when the next garbage collection will occur. The column max used reports the maximum memory that was used since the last call to the gc() function.

Does GC collect release memory?

Memory releaseWhen the garbage collector performs a collection, it releases the memory for objects that are no longer being used by the application. It determines which objects are no longer being used by examining the application's roots.


1 Answers

Under the initial line it tells you the totals in con cells(Ncells -that is a 28 byte for 32 bit system and 56 bytes for a 64 bit system... ) then the total in vector cells (Vcells , they are 8 bytes)

The following table just breaks down how it was distributed:

The number cleared now under used, the number which would have triggered automatically and the max used PRIOR to gc() in the third column is the amount used since the prior reset.

If you want to see more details ?gc() in the console.....you get it all! And the base manual for R explains how garbage collection works. And ?Memory gives you an idea of how memory is allocated.

Edit: Finally, to see the results of a garbage collection, you could use an external resource monitoring applications. In windows, that just amounts to keeping the Task Manager open. In unix/linux, you could consult htop, or in macOS, the Activity Monitor app.

like image 197
sconfluentus Avatar answered Sep 27 '22 22:09

sconfluentus