about Enum.values() memory allocation
Michael Rasmussen
Michael.Rasmussen at roguewave.com
Wed Jul 25 09:22:25 UTC 2018
With condy being added in Java 11, this could potentially be a use-case for that ?
for (EnumType e: const(EnumType.values())) { ... }
Or perhaps it's time to add a List<E> valuesList(); to enum types, that returns an immutable List of the values?
/Michael
________________________________
From: compiler-dev <compiler-dev-bounces at openjdk.java.net> on behalf of nezih yigitbasi <nezihyigitbasi at gmail.com>
Sent: 25 July 2018 08:23:57
To: compiler-dev at openjdk.java.net
Subject: about Enum.values() memory allocation
Hi,
I recently noticed in our app that Enum.values() allocates a significant amount of memory when called in a tight loop as it clones the constant values array (which is probably for immutability, and I can understand that). I found that the same issue has been discussed back in 2012: http://mail.openjdk.java.net/pipermail/compiler-dev/2012-March/004210.html
Are there any plans to address this issue going forward?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180725/d8d8afd7/attachment.html>
More information about the compiler-dev
mailing list