kaneplusplus / bigmemory

126 stars 24 forks source link

Suggestion: Remove temporary (anonymous) backing files on gc() #92

Open jonpeake opened 5 years ago

jonpeake commented 5 years ago

After monitoring disk usage and watching the size of my /tmp folder increase steadily with each new big.matrix, I finally noticed the line in the package description about these not being deleted automatically until the R session is closed. I'm not even sure if this is possible, but if it is, it would be nice if we were able to automatically remove anonymous backing files after the R-object is deleted and gc() is called. Just something to think about.

kaneplusplus commented 5 years ago

I think it's a good suggestion. Your '/tmp' file is probably filling up because of the temporary objects that are created during matrix computations with bigmemory. Under normal circumstances, we don't know if the binary file is going to be used beyond the scope of the big.matrix object that references it. You could add a flag that says delete this object in the finalizer. If we do this, we'd have to make sure there is a mechanism for a "temporary" big.matrix object to become a persistent one so that if the matrix you are interested in is returned as temporary, there is a mechanism to save it.