Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress output of gc()

Is there a possibility to suppress all messages of gc( ) in R?

The usual like suppressWarnings(gc( )) or suppressMessages(gc( )) don't work. gc( ) itself has a verbose option but this is not working how I like it:

> gc(verbose=TRUE)
Garbage collection 375 = 234+40+101 (level 2) ... 
17.9 Mbytes of cons cells used (41%)
171.2 Mbytes of vectors used (43%)
used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   334493  17.9     818163  43.7   818163  43.7
Vcells 22431904 171.2   52178020 398.1 50193465 383.0
> gc(verbose=FALSE)
used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   334496  17.9     818163  43.7   818163  43.7
Vcells 22431916 171.2   52178020 398.1 50193465 383.0

Thanks in advance!

like image 394
Martingales Avatar asked Dec 12 '13 14:12

Martingales


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.

How do you disable garbage collection in Python?

Since the collector supplements the reference counting already used in Python, you can disable the collector if you are sure your program does not create reference cycles. Automatic collection can be disabled by calling gc. disable() .

What does GC collect () do?

It performs a blocking garbage collection of all generations. All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected. Use this method to force the system to try to reclaim the maximum amount of available memory.


1 Answers

I sometimes use invisible(gc()).

like image 50
TheComeOnMan Avatar answered Sep 30 '22 09:09

TheComeOnMan