Way back, last year, the following was posted. This may be
contributing to your observed leak.
-----Original Message-----
From: Eliyas Yakub [mailto:xxxxx@microsoft.com]
Sent: Thursday, July 29, 1999 11:15 AM
To: ‘Steve Hayward’
Cc: ‘xxxxx@atria.com’
Subject: RE: [ntdev] IoCreateDevice/IoDeleteDevice memory leak
Yes it’s a bug. It will be fixed in the post Win2K release. This memory leak
will happen only if you specify one of the following as your device type.
FILE_DEVICE_DISK
FILE_DEVICE_TAPE
FILE_DEVICE_CD_ROM
FILE_DEVICE_VIRTUAL_DISK
These values are specified only by storage devices, and at least on NT4.0,
once created these device objects are not deleted at all. Anyway thanks for
your feedback.
Eliyas
-----Original Message-----
From: Steve Hayward [mailto:xxxxx@avantis.co.uk]
Sent: Thursday, July 29, 1999 2:51 AM
To: Eliyas Yakub
Subject: RE: [ntdev] IoCreateDevice/IoDeleteDevice memory leak
Eliyas
Thanks for your response I have found now the leak.
It seems that the IoDeleteDevice does not free the the VPB block. The
following code plugs the leak.
// extract the pointer to the Vpb
pVpb = pNewDeviceObject->Vpb;
// first free the VPB if it exits
if(pVpb != NULL)
{
// set value in the device object to NULL
pNewDeviceObject->Vpb = NULL;
// now free the buffer
ExFreePool(pVpb);
}
// now delete the device
IoDeleteDevice(pNewDeviceObject);
This is also backed up by the fact that creating devices as
FILE_DEVICE_UNKNOWN does not have the same leak problem.
Steve
[ To unsubscribe, send email to xxxxx@atria.com with body
UNSUBSCRIBE (the subject is ignored). ]