Replies: 1 comment
-
Hello, The StorageEntityCache does more then just caching. It also holds the information of all objects that are peristed. This includes objects that are currently not materialized as java objects into memory. This information is crucial for lazy loading and the storage garbage collector to decide if an entity can be removed from the persisted data. This also applies to immutable objects, therefore they can’t be excluded from the StorageEntityCache. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you profile MS memory allocations, you will find StorageEntity$Default and BinaryStorer$Item are the most allocated objects, consume about 10% memory of total heap size.
Based on my understanding, the
BinaryStorer
is used to record whether each object has been persisted, so there is little room for optimization. TheStorageEntity
is used to record the storage information of each persisted object and can be collected by the MS GC following the JVM GC, or invalidated by theStorageEntityCache
after cache timeout.For immutable objects, such as
String
,Integer
,Record
, and other types, after they are persisted, they cannot be modified. Therefore, it appears unnecessary to cache theirStorageEntity
withinStorageEntityCache
.Hence, could an optimization be made where, if the object is immutable, a
StorageEntity
is not cached in theStorageEntityCache
?The method that would be impacted is:
This suggests a potential enhancement where the creation/cache of
StorageEntity.Default
instances for immutable objects insideStorageEntityCache
could be avoided, which could lead to reduced memory allocations for these objects and decrease the overall memory consumption within the heap.Beta Was this translation helpful? Give feedback.
All reactions