哪里是List< MyClass的>对象缓存维护?它是在RAM或HDD? [英] Where is the List<MyClass> object buffer maintained? Is it on RAM or HDD?

查看:137
本文介绍了哪里是List< MyClass的>对象缓存维护?它是在RAM或HDD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题可能听起来有点含糊。但我想知道的是,其中的名单,其中;> 缓冲区保持

我有一个列表名单,其中,MyClass的> 来,我是来自一个无限循环添加项目。但是,Windows服务(在我制作的列表)的内存消耗从未超越17 MB。事实上,它徘徊,即使我继续将项目添加到列表15-16MB之间。 我试图做我的服务的某些负载测试,并发现了这件事。

谁能告诉我它是否转储数据到设备上的一些临时的位置,并从那里挑选,因为我没有看到增加内存的消耗。

这我打电话无限的方法是AddMessageToList()。

 类MainClass
{
    名单< MessageDetails> messageList的=新的名单,其中,MessageDetails>();
    私人无效AddMessageToList()
    {
        SendMessage函数(应用程序名称,地址,邮件);
        MessageDetails OBJ =新MessageDetails();
        obj.ApplicationName =应用程序名称;
        obj.Address =地址;
        obj.Message =消息;
        锁定(messageList的)
        {
            messageList.Add(OBJ);
        }
    }
}
类MessageDetails
{

    公共字符串消息
    {
        得到;
        组;
    }
    公共字符串应用程序名称
    {
        得到;
        组;
    }
    公共字符串地址
    {
        得到;
        组;
    }
}
 

解决方案

在回答你的问题是:内存

这意味着RAM中,它也可以指硬盘驱动器(虚拟存储器)。操作系统的内存管理器确定何时进行页面的内存虚拟内存,它主要是同频率内存访问(虽然我不pretend知道微软的具体算法)。

您还问,为什么你的记忆用法是不会了。首先,一兆字节的内存量巨大。除非你的类是相当大的,你需要他们的很多事情,使一个MB的出现。最终,你的内存使用情况应该,虽然上去了。

My question might sound a little vague. But what I want to know is where the List<> buffer is maintained.

I have a list List<MyClass> to which I am adding items from an infinite loop. But the RAM consumption of the Windows Service(inside which I am creating the List) never goes beyond 17 MB. In fact it hovers between 15-16MB even if I continue adding items to the List. I was trying to do some Load Testing of My Service and came across this thing.

Can anyone tell me whether it dumps the data to some temporary location on the machine, and picks it from there as I don't see an increase in RAM consumption.

The method which I am calling infinitely is AddMessageToList().

class MainClass
{
    List<MessageDetails> messageList = new List<MessageDetails>();
    private void AddMessageToList()
    {
        SendMessage(ApplicationName,Address, Message);
        MessageDetails obj= new MessageDetails();
        obj.ApplicationName= ApplicationName;
        obj.Address= Address;
        obj.Message= Message;            
        lock(messageList)
        {
            messageList.Add(obj);
        }
    }
}
class MessageDetails
{

    public string Message
    {
        get;
        set;
    }
    public string ApplicationName
    {
        get;
        set;
    }
    public string Address
    {
        get;
        set;
    }
}

解决方案

The answer to your question is: "In Memory".

That can mean RAM, and it can also mean the hard drive (Virtual Memory). The OS memory manager decides when to page memory to Virtual Memory, which mostly has to do with how often the memory is accessed (though I don't pretend to know Microsoft's specific algorithm).

You also asked why your memory usages isn't going up. First off, a MegaByte is a HUGE amount of memory. Unless your class is quite large, you will need a LOT of them to make a MB appear. Eventually your memory usage should go up though.

这篇关于哪里是List&LT; MyClass的&GT;对象缓存维护?它是在RAM或HDD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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