RFR 8198997: Cache normalized/resolved user.dir property
Claes Redestad
claes.redestad at oracle.com
Mon Mar 12 18:53:10 UTC 2018
Hi Brian,
I expect the original user.dir property to be kept resident in memory by
System.properties
(thus no memory loss), and going from a boolean field to an Object
reference field on an
object that I expect to be a singleton(?) is unlikely to be a footprint
concern[1].
/Claes
[1] Chances are the two approaches are footprint neutral on most archs
due to padding.
On 2018-03-12 19:46, Brian Burkhalter wrote:
> Hi Claes,
>
> That was what I had originally but did not post as I did not like the
> extra String variable increasing the memory footprint. Of course this
> would only be true were the user.dir accessed at all.
>
> Thanks,
>
> Brian
>
> On Mar 12, 2018, at 11:42 AM, Claes Redestad
> <claes.redestad at oracle.com <mailto:claes.redestad at oracle.com>> wrote:
>
>> Instead of a volatile boolean and a mutable userDir field, couldn't
>> this just
>> as well be modelled as:
>>
>> - keep userDir final (always the not normalized value of
>> System.getProperty("user.dir"))
>> - replace volatile boolean isUserDirNormal with volatile String
>> normalizedUserDir
>> - then implement the DCL in getUserPath like:
>>
>> String normalizedUserDir = this.normalizedUserDir;
>> if (normalizedUserDir == null) {
>> synchronized(userDir) {
>> if (normalizedUserDir == null) {
>> normalizedUserDir = this.normalizedUserDir = normalize(userDir);
>> }
>> }
>> }
>> return normalizedUserDir;
>
More information about the core-libs-dev
mailing list