Showing archive results for 2011

Sep 26, 2011
Post comments count0
Post likes count1

Sending a window a WM_DESTROY message is like prank calling somebody pretending to be the police

Raymond Chen

A customer was trying to track down a memory leak in their program. Their leak tracking tool produced the stacks which allocated memory that was never freed, and they all seemed to come from , which is a DLL that comes with Windows. The customer naturally contacted Microsoft to report what appeared to be a memory leak in Windows. I was one of th...

Code
Sep 23, 2011
Post comments count0
Post likes count1

Why does my asynchronous I/O complete synchronously?

Raymond Chen

A customer was creating a large file and found that, even though the file was opened with and the call was being made with an structure, the I/O was nevertheless completing synchronously. Knowledge Base article 156932 covers some cases in which asynchronous I/O will be converted to synchronous I/O. And in this case, it was scenario number thre...

Code
Sep 22, 2011
Post comments count0
Post likes count1

Why does my single-byte write take forever?

Raymond Chen

A customer found that a single-byte write was taking several seconds, even though the write was to a file on the local hard drive that was fully spun-up. Here's the pseudocode: The customer experimented with using asynchronous I/O, but it didn't help. The write still took a long time. Even using (and writing full sectors, naturally) didn't he...

Code
Sep 20, 2011
Post comments count0
Post likes count0

Random notes from //build/ 2011

Raymond Chen

Here are some random notes from //build/ 2011, information of no consequence whatesoever. A game we played while walking to and from the convention center was spot the geek. "Hey, there's a guy walking down the street. He's wearing a collared shirt and khakis, with a black bag over his shoulder, staring into his phone. I ...

Other
Sep 20, 2011
Post comments count0
Post likes count1

Microspeak: The bug farm

Raymond Chen

In its most general sense, the term bug farm refers to something that is a rich source of bugs. It is typically applied to code which is nearly unmaintainable. Code can arrive in this state through a variety of means. The term is most often used as a cautionary term, calling attention to areas where there is high risk that code you're about to ...

OtherMicrospeak
Sep 19, 2011
Post comments count0
Post likes count1

The clipboard viewer linked list is no longer the responsibility of applications to maintain, unless they want to

Raymond Chen

Commenter Nice Clipboard Manager (with drop->clipboard) wonders why Windows still uses a linked list to inform programs about clipboard modifications. If any clipboard viewer fails to maintain the chain, then some windows won't get informed of the change, and if a clipboard viewer creates a loop in the chain, an infinite loop results. Well, ...

Code
Sep 16, 2011
Post comments count0
Post likes count1

Why can't I PostMessage the WM_COPYDATA message, but I can SendMessageTimeout it with a tiny timeout?

Raymond Chen

After receiving the explanation of what happens to a sent message when reaches its timeout, a customer found that the explanation raised another question: If the window manager waits until the receiving thread finishes processing the message, then why can't you post a message? "After all, with a very short timeout isn't all that different from ...

Code
Sep 15, 2011
Post comments count0
Post likes count0

Some preliminary notes from //build/ 2011

Raymond Chen

Hey everybody, I'm down at the //build/ conference. (The extra slash is to keep the d from falling over.) I'm not speaking this year, but you can find me in the Apps area of the Expo room today until 3:30pm (except lunchtime), and Friday morning before lunch. I'll also be at Ask the Experts tonight. There are so many great sessions to choose from....

Non-Computer
Sep 15, 2011
Post comments count0
Post likes count1

What happens to a sent message when SendMessageTimeout reaches its timeout?

Raymond Chen

The function tries to send a message, but gives up if the timeout elapses. What exactly happens when the timeout elapses? It depends. The first case is if the receiving thread never received the message at all. (I.e., if during the period the sender is waiting, the receiving thread never called , , or a similar message-retrieval function which d...

Code