关于资源泄漏,讨论一下!

o_lb_o 2002-11-29 02:55:32
到底什么是资源泄漏?应该首先研究一下什么是资源,从MSDN上的解释,资源定义有几个:
1 A piece of static data, such as a dialog box, that can be used by more than one application or in more than one place within an application. Alternatively, any part of a computer or network, such as a disk drive, printer, or memory, that can be used by a program or process.

2Binary data the resource compiler or developer adds to an application's executable file. Windows resources include icons, cursors, menus, dialog boxes, bitmaps, fonts, keyboard-accelerator tables, message-table entries, string-table entries, version data, and user-defined data.

定义1比定义而更广,却更不容易把握,不知道哪里能找到更准确的定义?希望听到大家的高见.
...全文
21 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
endless2000 2003-05-06
  • 打赏
  • 举报
回复
常见的资源泄漏有:画笔、数据库连接、字体、设备上下文、窗口、时钟、信号量、线程、进程、文件等系统资源的泄漏.

参见boundschecker帮助中的说明:
Resource leak:
A system resource (HBRUSH, DLL, file etc.) was created or opened and never freed or closed.

When your program terminates, checking occurs to ensure you have freed all allocated blocks of memory and resources, and all blocks and resources still allocated, along with their size and location, are automatically listed.

Note: If you are not seeing source code for the leak then it is likely that the allocating module does not have debug information. This occurs mostly with third party packages or system code. However, you are provided with the address which can be used to determine the source line where the memory was allocated.

C++ Sample Code

...
hResource = LoadResource (hInstance,

FindResource (hInstance, "TEXT", RT_STRING) );

/* without a later FreeResource statement */
...

Pascal Sample Code

The following shows a similar error in Pascal code.

procedure BitmapLeak;
var
hBitmap: THandle;
begin
hBitmap := CreateBitmap(80,80,1,8,NIL);
end;
termite 2002-12-05
  • 打赏
  • 举报
回复
user object leak, u can find more info from windows help.

5,177

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 质量管理/软件测试
功能测试压力测试安全性测试 个人社区 湖南省·长沙市
社区管理员
  • 软件测试
  • 虫无涯
  • 小博测试成长之路
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家加入到软件测试的社区,在这里,希望大家勇于发表自己的看法,欢迎大家分享自己在软件测试工作过程中遇到的问题以及工作经验分享。

1.想转行的小伙伴,遇到问题没有及时回复的,可以私聊小博进行反馈

2.大家对社区有好的建议,都可以在社区发帖进行反馈

推荐大家学习的软件测试入门笔记:软件测试入门学习笔记

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