[Rprotobuf-yada] finalizer for messages

Dirk Eddelbuettel edd at debian.org
Wed Dec 16 18:05:42 CET 2009


On 16 December 2009 at 17:26, Romain Francois wrote:
| I think the problem is now solved, and we have a cleaner package that 
| plays well (at least I think) with R's garbage collector.
| 
|  > require( RProtoBuf )
| Loading required package: RProtoBuf
| Loading required package: Rcpp
|  > message <- new( tutorial.Person, id = 1 )
|  > message <- new( tutorial.Person, id = 1 )
|  > message <- new( tutorial.Person, id = 1 )
|  > message <- new( tutorial.Person, id = 1 )
|  > gc()
| RProtoBuf finalizing Message (0x9258f68)
| RProtoBuf finalizing Message (0x91ce378)
| RProtoBuf finalizing Message (0x97f27b0)
|           used (Mb) gc trigger (Mb) max used (Mb)
| Ncells 260797  7.0     407500 10.9   350000  9.4
| Vcells 210014  1.7     786432  6.0   500691  3.9
| 
| previously the 3 first messages did not free their memory after the 
| external pointer was GC'd.
| 
| I'll leave debugging messages as above for some time.

I had to look at that for second .... so we get three finalizers / cleanups
because out of four allocations, only one is reachable?

Nifty, my friend, very nifty!

Dirk

-- 
Three out of two people have difficulties with fractions.


More information about the Rprotobuf-yada mailing list