About | Buy Stuff | News | Products | Rants | Search | Security
Home » Resources » Software » Reviews » Rainmaker Redux

Rainmaker Redux V:

Gimme Back My Box!

Device contexts come with toolboxes. In each toolbox there is one tool for each possible task. Want to draw a bitmap? Your toolbox has a bitmap. Want to print something on screen with a font? Your toolbox has a font. Want to erase all or part of your background? Your toolbox has a brush. Want to draw some lines, some circles, some rounded rectangles? Your toolbox has a pen. And so forth. Any GDI operation you can conceive of has a tool present in the device context.

The problem is that each of these tools represents an allocation on the part of the system. The system lends the toolbox to you but wants it back intact. The system has to gobble up memory to hold the font, the brush, the pen, the what-not, and when the system gets them back, it will free them all and recover the memory they used - if the system gets them back, and only if you remember to return the toolbox intact.

That's the first mistake. People used device contexts but got things mixed up and the system couldn't access all its tools afterwards and free the memory they used.

And if the user (of the device context) didn't like the font provided, wanted another brush or pen and created a new one for painting, it took memory too - memory which should be freed when the painting operation is done. But sure enough, the Turings of our day regularly forgot about this 'minor' detail too.

So lots of memory was lost in this fashion. And there was no way to get it back.

And the reason was that the GDI database where all this memory was held had too little storage capacity. It didn't have enough room to store the identity of the owner of the objects it held the allocations for. It couldn't cross-check its list with a list of running tasks and free memory for objects whose owners had hit the road.

Programmers talked back then about the advent of Win32. In Win32, it was promised, this would be different. The same constraints would not be there on the GDI's database. It would be possible to identify the owner of an object listed in said database, establish whether said owner no longer existed, and free said object. A boon waiting on the horizon.

  The Greatest Event in Computing Science Since

About | Gallery | News | Order the XPT | Products | Resources | Security | Services | Workshop
Copyright © Radsoft. All rights reserved.