After doing memory profiling recently with dotMemory, we discovered that there were over a hundred thousand duplicate strings in memory amounting to over 40 MB. As a data-heavy app we are looking to pare down everywhere we can.
Looking at the profile, almost all of it comes from the getter on EntityRelationLink.UniqueName. It has to concatenate strings, so the string doesn't get interned by default, even though as a unique name I'd imagine it doesn't change very much. Is there any way to force interning on this string?
There's probably nothing you can do from the application side to modify this behavior.
The issue might be more apparent with large models when doing a lot of 1) entity graph imports, 2) work with the EntityCacheState, or 3) querying of entity graphs. Although you are seeing a significant number of duplicate strings, the good news is that they should be available for garbage collection.
We can look at addressing this behavior, although I don't know that interning is the answer in this case. When the EntityServer is hosted by IIS we'd want to avoid having interned strings outlive the EntityServer. Model metadata, such as the EntityRelationLink, is generally immutable after it's loaded, so there should be some optimizations we can make in the UniqueName getter to avoid the repetitive string concatenation it's doing.
Which version of DevForce are you using?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With