DelphiXE下的内存管理

自Delphi2007开始使用了FastMM作为内存管理器,替代了原有的颇受诟病的自带内存管理。使用也非常方便,只要在工程文件的源码里使用下面的一行代码即可。

ReportMemoryLeaksOnShutdown := True;

当程序关闭时,会自动检测内存泄露,并弹出提示框。

FastMM 是适用于delphi的第三方内存管理器,在国外已经是大名鼎鼎,在国内使用率也很高,网上也不乏介绍它的文章。可以到

Delphi 中少见的第三方内存管理器,QStrings 的作者 Andrew Driazgov 发布 QMemory is a new memory manager. You can use it as a replacement of the default system memory manager. To do this simply add QMemory unit in your project (as the first unit listed in the project file). Don‘t forget to call the QMemDecommitOverstock function when your application is idle. This subroutine decommits the unused memory blocks (it‘s only way for program to return the memory to the operation system). All allocated memory blocks are 32 byte aligned. The minimum size of the block is 32 bytes. As it is necessary to store some information with each block a dword is attached to the front of each block at -4 the aligned address. Thus, memory request for up to 28 bytes allocates a 32-bytes block, request for 29 to 60 bytes allocates a 64-bytes block, etc (as power of 2). This idea was adopted from HPMM project of Robert Lee (rhlee@optimalcode.com). The memory is committed and decommitted in 64K blocks. The maximum amount of the memory is specified when QMemInstall function is called (from the initialization section of the unit). You can‘t change this value later. If some parts of your program implemented as DLLs you have to use ShareQmm instead of QMemory unit. ShareQmm must be the first unit in your library‘s USES clause AND your project‘s (select Project-View Source) USES clause if some parts of your program have done as separate DLLs (especially if they export any procedures or functions that pass strings as parameters or function results). ShareQmm is the interface unit to the QMM.DLL shared memory manager, which must be deployed along with your DLL. You can‘t combine using of the standard ShareMem and custom ShareQmm memory managers in the same program project (including EXE-file with all DLLs). You can use either ShareMem or ShareQmm, but not both together. ShareQmm memory manager works at the same speed as a ShareMem memory manager with the blocks up to 4096 bytes and much more faster with the larger blocks.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值