3 ms·
So every time you take the hash of a string you leak 4 bytes of memory??? I assume it's static in the context of it's containing object. So, it will be collect
by pkulak 1y ago
So every time you take the hash of a string you leak 4 bytes of memory???
I assume it's static in the context of it's containing object. So, it will be collected when it's string is collected.
- nimrody 1y agoNo. The string hash is stored as part of the String object. It is initialized to 0 but gets set to the real hash of the string on first call to hashCode() (which is why it will be computed over and over again if your special string happens to hash to 0)