Measure an object's size in memory and serialised
Source:R/margot_lmtp_memory_preflight.R
margot_lmtp_object_size.RdReturns the in-memory size reported by utils::object.size() and the length of the object's serialised form, length(serialize(x, NULL, version = 3L)), which is the form margot_lmtp_checkpoint_compute() writes. Use it on objects built from generated fixtures at the study's number of participants and variables, so that margot_lmtp_memory_preflight() receives measured sizes rather than guesses. object.size() does not count the contents of environments and counts shared memory once for each reference, so it can report almost nothing for an object whose data sit in an environment (a fitted model's closure or an R6 object, for example); the serialised length includes environment contents, and the memory estimate rests mainly on it.