Freigeben über


When it leaks, it pours

Greetings from the Pacific Northwet.  After our recent Snow-pocalypse, we also suffered a run of flooding.  Amazingly enough, it wasn't directly due to the 13+ inches of snow I had at my house, it was a combination of the snow and the monumental amounts of rain that followed.  Quite a few people were literally cutoff from the rest of Washington State as their egress roads were under rivers.  The only hassle I had to suffer was one of FedEx being a day late with a new laptop.  Oh bother.

The leaking I did have to suffer was of my own doing. It was my usage of IWDFIoRequest::GetCompletionParams in a test driver.  In trying to be a good boy and clean up my I/O requests, and especially since I was going to be using asynchronous I/O, I wanted to get the completion parameters with out having to mess around with a completion routine.  Funny thing is, that call takes a reference on the pointer returned.  All was fine and dandy until I turned on Object leak detection (using WdfVerifier) and reference tracking.  Debugger breaks prevent things from running smoothly I've found. :)

Now those of you much smarter than me would have told me I could have avoided that by using the CComPtr class on the CompletionParams interface as shown in the sample, but if you're like me and still think you know better and didn't use the CComPtr class, you had best make a subsequent Release() call.

 pWdfRequest->GetCompletionParams (&CompletionParams);

hr = CompletionParams->GetCompletionStatus ();
CompletionParams->Release();

*Currently playing - Porcupine Tree Blackest Eyes