romainfrancois commented on pull request #8256:
URL: https://github.com/apache/arrow/pull/8256#issuecomment-718045112


   This last commit is related to 
https://issues.apache.org/jira/browse/ARROW-10080 and gives a way to release 
memory immediately for RecordBatch and Table. If we want more classes (maybe 
Array etc ... ?) we can add them to generated code in `codegen.R`. 
   
   `$invalidate()` can be used on any arrow object but it only release the 
memory (i.e. call the destructor) if the method is generated: 
   
   ```r
   invalidate = function() {
         cl <- class(self)[1L]
         # if there is a Reset function for that class, call it
         reset <- get(paste0("_arrow_", cl, "__Reset"), ns_arrow)
         if (!is.null(reset)) {
           get(".Call")(reset, self)
         }
         # but in any case, set the external pointer to NULL
         assign(".:xp:.", NULL, envir = self)
       }
   ```
   
   otherwise it just sets the external pointer to NULL which is less useful 
because the memory will be reclaimed only later as part of a garbage 
collection. 
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to