Win32 API中“通用对话框"库的内存(RAM)问题 [英] A memory (RAM) problem with the Common Dialog Boxes library in the Win32 API

查看:113
本文介绍了Win32 API中“通用对话框"库的内存(RAM)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一些编程(C/C ++,JAVA,Win32 ..),但是我不知道计算机科学的高级概念.我只知道基本知识.此问题与Windows操作系统中的内存管理有关.您可以通过观察看到问题.

1.双击文件,使用记事本打开文件.
2.打开任务管理器,在进程"选项卡下,您将找到Notepad.exe占用的内存(大约1,400 K)
3.然后使用记事本中使用的通用对话框"库打开一个文件(转到文件->打开).
4.现在,您将在任务管理器中看到Notepad.exe占用的内存约为8,000K.

这是为什么 ?并且即使关闭打开文件"对话框后,内存也不会更改.在关闭打开文件"对话框后,Windows(或库或其他任何东西)为什么不释放内存.


需要一个好的答案!

[我正在使用Win7 64位)

I know some programming (C/C++, JAVA, Win32..), but I don''t know advanced concepts of Computer Science. I just know the basics. This question is about memory management in Windows Operating Systems. You can see the problem by just observing.

1. Open a file using Notepad by double clicking a file.
2. Open the Task Manager, and under processes tab you''ll find the memory taken by the Notepad.exe (it is about 1,400 K)
3. Then open a file using the Common Dialog Boxes Library which is used in Notepad (Goto File --> Open).
4. Now you''ll see the memory taken by Notepad.exe in the Task Manager as about 8,000 K.

Why is that ? And Even After when closing the Open File Dialog, the memory will not change. Why isn''t Windows (or the library or anything else) freeing the memory after closing the Open File Dialog.


Need a good Answer !

[I''m using Win7 64bit)

推荐答案

正如Wes所说,任务管理器告诉您进程已分配了多少RAM供使用,而不是它正在使用很多.这对于模糊的想法或显示失控的过程非常有用,但是对于您想要的粒度而言,它并不准确.
As Wes said, the task manager is telling you how much RAM the process has allocated to it for use, not how much it is using. It is good for a vague idea, or to show a runaway process, but it''s not accurate at the granularity you''re wanting it to be.


我可以给您一个如果您遇到内存分配问题(例如内存泄漏)或内存不足问题,请使用更具体的想法.您需要的产品类型称为内存调试器".

您可以从以下列表中找到适合您的一个:
http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools [ http://msdn.microsoft.com/en-us/library/x98tx3cf%28v = vs.100%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx [ ^ ].

如果您使用诸如自动指针之类的更高级的技术,则可以改善您的内存处理体验并减少手工工作量,该技术为指针提供了有限的垃圾收集功能:
http://www.cplusplus.com/reference/std/memory/auto_ptr/ [ ^ ].

—SA
I can give you a more specific idea if you have problems with memory allocation, such as memory leak, of not-enough-memory problems. The type of product you need is called "memory debugger".

You can find the one suitable for you from this list:
http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools[^].

At least some of these products are open-source.

Another (but not alternative, it could be the additional) approach is the validating library which you can use during run-time. Such library intercepts/replaces C++ memory allocation operations and count the balance. It can pinpoint the object where the memory is not completely released. Unfortunately, I cannot point you a particular 3rd-party library which you can use with contemporary C++ compilers, but if you use Visual Studio, you can use its debugger along with CRT libraries to detect and pinpoint memory leaks. Please see:
http://msdn.microsoft.com/en-us/library/x98tx3cf%28v=vs.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx[^].

You can improve your memory handling experience and reduce amount of manual work if you use some more advanced techniques like automatic pointers, which provide limited garbage collection facility for pointers:
http://www.cplusplus.com/reference/std/memory/auto_ptr/[^].

—SA


这篇关于Win32 API中“通用对话框"库的内存(RAM)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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