本文介绍了你怎么知道一个班级使用了多少内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想知道如何计算一个类的给定实例 使用多少内存。 例如,如果我加载一个包含10个项目的集合类,它可能会使用1KB,如果我加载1000个项目,它可能会使用100KB。 如何测量使用的内存量一旦上课了吗? 谢谢! - Joe Fallon 解决方案 < URL: http://www.gotdotnet.com/Community/U...px?SampleGuid= 3254325d-a4aa-4bb3-aa86-c72d5104ec74> - Herfried K. Wagner [MVP] < URL:http://dotnet.mvps .org /> < URL: http://www.gotdotnet.com/Community/U...px?SampleGuid= 3254325d-a4aa-4bb3-aa86-c72d5104ec74> I would like to know how you can figure out how much memory a given instanceof a class is using.For example, if I load a collection class with 10 items it might use 1KB,and if I load it with 1000 items it might use 100KB.How do I measure the amount of memory used once the class is loaded?Thanks!--Joe Fallon 解决方案All you can do is using a memory profiler. I am not sure if this willwork as you expect it to do.<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>--Herfried K. Wagner [MVP]<URL:http://dotnet.mvps.org/><URL:http://www.gotdotnet.com/Community/U...px?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74> -- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/><URL:http://www.gotdotnet.com/Community/U...px?SampleGuid= 3254325d-a4aa-4bb3-aa86-c72d5104ec74> 这篇关于你怎么知道一个班级使用了多少内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 06:28
查看更多