DEV Community

Discussion on: Strings Are Evil

Collapse
 
vigzel profile image
vigzel

Hi, I noticed in your code that you are creating ValueHolder/ValueHolderAsStruct but you don't store it in a list.
If that line is uncommented (in v11), so that ValueHolderAsStruct is stored in a list, then memory allocation goes up to around 1 GB.
What is interesting is that if I then replace ValueHolderAsStruct with ValueHolder class, allocated memory actually goes down almost by half to 523MB.
It seems that for some reason it's actually "cheaper" to hold a list of classes that a list of structs. Do you know why this may be?