关于专用字节的使用 [英] regarding Private bytes usage

查看:99
本文介绍了关于专用字节的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我正在监视某些服务应用程序的性能.但是,这样做时,我在运行perfmon实用程序时看到了专用字节的跳跃.仅当我分配的内存大于abt 4k或8k时,才会发生这种情况.但是,当调用任何数组的delete []时,我是 预计会下降.如果您使用perfmon监视下面的示例代码,则会模拟相同的行为.启动程序并立即启动perfmon

I am monitoring a perfmon for some service app. However while doing so I saw a jump in the private bytes when running perfmon utility. This happens only when I allocate memory larger than abt 4k or 8k. Howver when a delete[] of any array is called, I was expecting to see a drop. If you monitor the follwoing sample code using perfmon, the same behaviour is simulated . Start the program and start perfmon immediately

void main()
{
 
  BYTE * buff1 = NULL;
  BYTE * buff2 = NULL;
 <<<<"睡眠10秒-注意私有字节的初始值降低"<<< endl;
  Sleep(10000);
 
  int isize1 = 5000;
  buff1 =新的BYTE [isize1];
 < cout<"休眠10秒-在首次分配< isize1<字节"< endl;< endl;< br/>   Sleep(10000);
 删除[] buff1;

void main()
{
 
 BYTE* buff1 = NULL;
 BYTE* buff2 = NULL;
 cout<<"Sleeping for 10secs-Note down initial value for private bytes"<<endl;
 Sleep(10000);
 
 int isize1=5000;
 buff1 = new BYTE[isize1];
 cout<<"Sleeping for 10secs-Note down private bytes after first allocation of"<<isize1<<"bytes"<<endl;
 Sleep(10000);
 delete [] buff1;

  cout<"已分配的已删除字节数"<<< endl;
  Sleep(30000);
  buff2 = NULL;

 cout<<"Deleted allocated bytes"<<endl;
 Sleep(30000);
 buff2 = NULL;

  int isize2 = 8000;
  buff2 =新的BYTE [isize2];
 < cout<"休眠30秒-在第二次分配< isize2< bytess< endl;< endl;
  Sleep(30000);
 删除[] buff2;
 

 int isize2=8000;
 buff2 = new BYTE[isize2];
 cout<<"Sleeping for 30secs-Note down private bytes after second allocation of "<<isize2<<"bytess"<<endl;
 Sleep(30000);
 delete [] buff2;
 

  
}

  
}

即使调用delete [] buff1,也看不到私有字节丢弃.

Even if delete [] buff1 is called the private bytes drop is not seen.

如果第二个分配的碰巧小于第一个,例如:1000,则私有字节将丢失.如果对此观察有任何文档或理由,则需要帮助.

Also if the second arry allocated happens to be less than the first one say for eg: 1000 then the private bytes drops. Help needed if theres any documentation or justification for this observation.

 

推荐答案

进程的私有字节是一个令人困惑的话题.实际上,这是交换设备上分配的空间量,用于在交换出进程的情况下保存进程的私有内存的内容.

A process's private bytes is a confusing topic.  It is really the amount of space allocated on swap devices to hold the contents of a process's private memory in the event that the process gets swapped out.

分配内存时,该空间需要立即增加以适应进程专用内存的增加,以防万一它被换出.但是,当您删除空间时,通常没有立即紧迫的措施来减少 分配的空间量.暂时有一点额外的交换空间不是问题.如果该进程接下来执行另一次新的内存分配,则它可能已经具有足够的交换空间来容纳它而无需执行任何操作. 添加更多新语句和delete语句可能会显示此内容.

When you allocate memory, that space needs to be immediately increased to accommodate for the increase in the process's private memory, just in case it gets swapped out.  But when you delete space, there is usually no immediate urgency to reduce the amount of allocated space.  Having a little extra swap space on a temporarily basis is not a problem.  If the process next does another new memory allocation, then it might already have enough swap space to accommodate it without having to do anything.  Adding a few more new and delete statements might show this.


这篇关于关于专用字节的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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