物理内存发生跳跃

shawn 2013-02-25 12:51:13
想问下公司内部开发的某个服务进程占用内存发生明显的大范围跳跃,这是虚存使用过度导致的还是什么其他的原因呢?
...全文
274 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Red_angelX 2013-03-28
  • 打赏
  • 举报
回复
我猜也是资源泄漏
shawn 2013-03-28
  • 打赏
  • 举报
回复
引用 10 楼 zhao4zhong1 的回复:
引用 9 楼 jaff20071234 的回复:引用 8 楼 zhao4zhong1 的回复:用 VMMap http://technet.microsoft.com/zh-cn/sysinternals/dd535533 查看内存资源占用以及堆内存碎片情况。 哈哈, thanks, 找到原因了,垃圾代码导致new出大块内存,因是维护别人的代码,不了解所以没能快……
呵呵,个人不完全赞同这个观点。
赵4老师 2013-03-25
  • 打赏
  • 举报
回复
引用 9 楼 jaff20071234 的回复:
引用 8 楼 zhao4zhong1 的回复:用 VMMap http://technet.microsoft.com/zh-cn/sysinternals/dd535533 查看内存资源占用以及堆内存碎片情况。 哈哈, thanks, 找到原因了,垃圾代码导致new出大块内存,因是维护别人的代码,不了解所以没能快速解决该问题。
程序员要做的不是尽力避免错误,而是聚焦在快速发现并改正错误。真正以快速方式轻易解决错误,“快速的失败”远胜过“预防错误”。Fred George
shawn 2013-03-24
  • 打赏
  • 举报
回复
引用 8 楼 zhao4zhong1 的回复:
用 VMMap http://technet.microsoft.com/zh-cn/sysinternals/dd535533 查看内存资源占用以及堆内存碎片情况。
哈哈, thanks, 找到原因了,垃圾代码导致new出大块内存,因是维护别人的代码,不了解所以没能快速解决该问题。
赵4老师 2013-02-25
  • 打赏
  • 举报
回复
用 VMMap http://technet.microsoft.com/zh-cn/sysinternals/dd535533 查看内存资源占用以及堆内存碎片情况。
shawn 2013-02-25
  • 打赏
  • 举报
回复
引用 3 楼 zhao4zhong1 的回复:
检查是否资源泄漏的办法之一: 在任务管理器 进程 查看 选择列 里面选择:内存使用、虚拟内存大小、句柄数、线程数、USER对象、GDI对象 让你的程序(进程)不退出,循环执行主流程很多遍,越多越好,比如1000000次甚至无限循环,记录以上各数值,再隔至少一小时,越长越好,比如一个月,再记录以上各数值。如果以上两组数值的差较大或随时间流逝不断增加,则铁定有对应资源的资……
提交的内存(虚拟内存)和物理内存都有波动,就是在执行过程中,其他的都可以接受。
majia2011 2013-02-25
  • 打赏
  • 举报
回复
没用好内存池呗 n年前小兆内存的时候,谁要是敢这么抖动,绝对会被老师k死
青松2 2013-02-25
  • 打赏
  • 举报
回复
猫腻啊
shawn 2013-02-25
  • 打赏
  • 举报
回复
引用 1 楼 whizer 的回复:
大范围跳跃是什么意思?能否详细描述一下.
使用mmap查看,heap突然变大然后突然变小,比如说从3G突然跳跃到7G,然后又变小, 服务也没多少请求要处理啊。
赵4老师 2013-02-25
  • 打赏
  • 举报
回复
检查是否资源泄漏的办法之一: 在任务管理器 进程 查看 选择列 里面选择:内存使用、虚拟内存大小、句柄数、线程数、USER对象、GDI对象 让你的程序(进程)不退出,循环执行主流程很多遍,越多越好,比如1000000次甚至无限循环,记录以上各数值,再隔至少一小时,越长越好,比如一个月,再记录以上各数值。如果以上两组数值的差较大或随时间流逝不断增加,则铁定有对应资源的资源泄漏! 用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe. Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example, c:\Debuggers\windbg.exe In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop. This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours. 设置ServicesPipeTimeout后需要重启系统才生效 Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.) If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
图灵狗 2013-02-25
  • 打赏
  • 举报
回复
有这个可能性。
whizer 2013-02-25
  • 打赏
  • 举报
回复
大范围跳跃是什么意思?能否详细描述一下.

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧