void LookasideTest(void)
{
//初始化Lookaside对象
PAGED_LOOKASIDE_LIST pageList;
ExInitializePagedLookasideList(&pageList,NULL,NULL,NULL,sizeof(MYDATASTRUCT),'1234',0);
#define ARRAY_NUMBER 50
PMYDATASTRUCT MyObjectArray[ARRAY_NUMBER]={0};
//模拟频繁申请内存
for (int i=0;i<ARRAY_NUMBER;i++)
{
MyObjectArray[i]=(PMYDATASTRUCT)ExAllocateFromPagedLookasideList(&pageList);
DbgPrint(TEXT("申请内存%d--%0x\n"),i,MyObjectArray[i]);
}
//模拟频繁回收内存
for (int i=0;i<ARRAY_NUMBER;i++)
{
DbgPrint(TEXT("释放内存%d--%0x\n"),i,MyObjectArray[i]);
ExFreeToPagedLookasideList(&pageList,MyObjectArray[i]);
MyObjectArray[i]=NULL;
}
//删除lookaside对象
ExDeletePagedLookasideList(&pageList);
return;
}
快速分配释放内存
最新推荐文章于 2024-01-16 18:33:20 发布