Skip to content
Prev 323014 / 398503 Next

Size of a refClass instance

Yes, I agree.  How does one conceptually achieve polymorphic behavior without instantiating 100,000s of instances?  Perhaps one way around this is to represent the data in an efficient R way -- i.e. a data.frame -- and create a set of re-usable singleton instances of different node types.  To perform some polymorphic operation on a node, a singleton gets assigned to a node in the tree.  But behavior such as node$parent() or node$child(1) will require a small pool of these singletons.  Doable, I think.

PS. FWIW, I found another strike against the "massive tree of refClass instances".  It's save().  save() appears to unnecessarily expand/duplicate refClass structures.  Write time becomes prohibitive and loading in the data structure again results in a far greater memory usage.
On May 3, 2013, at 9:47 AM, Jeff Newmiller wrote: