我怎样才能在HttpRuntime.Cache对象的大小? [英] How can I get the size of an object in the HttpRuntime.Cache?

查看:460
本文介绍了我怎样才能在HttpRuntime.Cache对象的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前存储许多不同类型的对象在ASP.NET HttpRuntime.Cache,我想知道是否有要弄清楚每个对象有多大的方式?


解决方案

看看这些问题:

获得一个场的大小与字节C#

了解.NET对象

在特别的,寻找乔恩斯基特在这些问题的答案。他们会告诉你为什么数量会不准确。

对于获得的估计,也没有办法做到这一点,除非有一定的标准,以满足您的对象。

例如,如果你在高速缓存中许多对象,共享引用了一些常见的对象实例,序列化出缓存将序列化掉那些常见的对象的副本,这些对象之一为好,膨胀的结果。

I am currently storing many different types of objects in the ASP.NET HttpRuntime.Cache and I was wondering if there is a way to figure out how big each object is?

解决方案

Look at these questions:

Getting the size of a field in bytes with C#
Find out the size of a .net object

In particular, look for Jon Skeet's answer in those questions. They will tell you why the number won't be accurate.

As for getting an estimate, there is no way to do that unless there are certain criteria to be met for your object.

For instance, if you have many objects in the cache, sharing references to some common object instances, serializing out one of those objects in the cache will serialize out a copy of those common objects as well, inflating the results.

这篇关于我怎样才能在HttpRuntime.Cache对象的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆