0

如何计算c#中缓存键存储时消耗的内存空间

4

2 回答 2

1

您可以使用作为 Visual Studio 插件的内存分析器。

http://blogs.msdn.com/b/dotnet/archive/2013/04/04/net-memory-allocation-profiling-with-visual-studio-2012.aspx

于 2014-02-17T11:47:58.780 回答
0

您可以通过查询垃圾收集器和缓存对象来找到有关应用程序内存的一般信息。我不确定如何找到缓存使用的确切内存,但这是了解应用程序内存消耗的一个步骤。

// returns the memory consumption of this process
//  This includes active objects, objects to be disposed, and items within cache.
//  Setting the parameter to 'true' will force a garbage collection before returning the results
GC.GetTotalMemory(false);

// This shows the maximum size available to the cache
//  These limits can be set within the app.config / web.config files
Cache.EffectivePrivateBytesLimit;
于 2014-02-17T11:58:22.933 回答