Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

There's no way to get the managed object size in memory #573

Closed
almez opened this issue Nov 5, 2017 · 3 comments
Closed

There's no way to get the managed object size in memory #573

almez opened this issue Nov 5, 2017 · 3 comments

Comments

@almez
Copy link

almez commented Nov 5, 2017

Hi,

There is no way to get the actual (or even an approximate) size of the cached object in the memory.

The case is, we have +100 customized cache for different purposes to accelerate our platform, for each cache we have

  • Cache MaxSize
  • Cache ConsumedSize
  • Cache RemainingSize

Whenever we insert some object to be cached, we should detect its size to re-calculate aforementioned cache properties.

I know that's a complex issue and depends on many factors, so far we have some workarounds but non of them is official and we afraid to be changed in any minor or major release.

Should you add any API to get the object size in the memory ? or at least Type size and then we can add the object-specific data length.

Related Topics

Workaround 1
What Microsoft says about this issue

@almez almez changed the title There's no way to get managed object size in memory There's no way to get the managed object size in memory Nov 5, 2017
@JanEggers
Copy link

you can use structs for your cache items and Marshal.Sizeof

@almez
Copy link
Author

almez commented Nov 13, 2017

It requires changing the structure that we've built the application with.
It may consider a workaround but not permanent solution

@danmoseley
Copy link
Member

Issue moved to dotnet/corefx #25396 via ZenHub

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants