From hpages at fredhutch.org  Wed Sep 30 01:03:51 2015
From: hpages at fredhutch.org (=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=)
Date: Tue, 29 Sep 2015 16:03:51 -0700
Subject: [Rd] making object.size() more meaningful on environments?
In-Reply-To: <560B0E47.6050909@fredhutch.org>
References: <560B05DF.9020103@fredhutch.org>
	<CADwqtCPzwmYLSVoA+9jea5_sO3WUhN8ZseHfm-3yO2Lu2ao99g@mail.gmail.com>
	<560B0E47.6050909@fredhutch.org>
Message-ID: <560B18D7.5020204@fredhutch.org>

On 09/29/2015 03:18 PM, Herv? Pag?s wrote:
> Hi Gabe,
>
> On 09/29/2015 02:51 PM, Gabriel Becker wrote:
>> Herve,
>>
>> The problem then would be that for A a refClass whose fields take up N
>> bytes (in the sense that you mean), if we do
>>
>> B <- A
>>
>> A and B would look like the BOTH take up N bytes, for a total of 2N,
>> whereas AFAIK R would only be using ~ N + 2*56 bytes, right?

Of course I should also add that this is actually the situation with
any object in R, not just refClass objects, because of the
copy-on-modification trick.

H.

>
> Yes, but that's still a *much* better situation than the current one in
> my opinion. More generally speaking counting shared memory for each
> object (or process) that uses it is a common, sensible, and accepted
> approach. No need to look far: a character vector is just a collection
> of pointers to stuff that is shared thru the global CHARSXP cache and
> AFAIK object.size() takes this stuff into account.
>
> H.
>
>>
>> ~G
>>
>>
>>
>> On Tue, Sep 29, 2015 at 2:42 PM, Herv? Pag?s <hpages at fredhutch.org
>> <mailto:hpages at fredhutch.org>> wrote:
>>
>>     Hi,
>>
>>     Currently object.size() is not very useful on environments as it
>> always
>>     returns 56 bytes, no matter how big the environment is:
>>
>>        env1 <- new.env()
>>        object.size(env1)  # 56 bytes
>>
>>        env2 <- new.env(hash=TRUE, size=75000000L)
>>        object.size(env2)  # 56 bytes
>>
>>        env3 <- list2env(list(a=runif(25000000), L=LETTERS))
>>        object.size(env3)  # 56 bytes
>>
>>     This makes it pretty useless on reference class instances and other
>>     objects that use environments internally for caching or other
>> purposes.
>>
>>     What about changing this and make it return something more
>> meaningful?
>>
>>     Cheers,
>>     H.
>>
>>     --
>>     Herv? Pag?s
>>
>>     Program in Computational Biology
>>     Division of Public Health Sciences
>>     Fred Hutchinson Cancer Research Center
>>     1100 Fairview Ave. N, M1-B514
>>     P.O. Box 19024
>>     Seattle, WA 98109-1024
>>
>>     E-mail: hpages at fredhutch.org <mailto:hpages at fredhutch.org>
>>     Phone: (206) 667-5791 <tel:%28206%29%20667-5791>
>>     Fax: (206) 667-1319 <tel:%28206%29%20667-1319>
>>
>>     ______________________________________________
>>     R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list
>>     https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>>
>> --
>> Gabriel Becker, PhD
>> Computational Biologist
>> Bioinformatics and Computational Biology
>> Genentech, Inc.
>

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] making object.size() more meaningful on environments?
=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=