Please enable JavaScript to view this site.

Memory Validator Help

Navigation: Examples > The example application

Handles and More Handles menus

Scroll Prev Top Next More

 

The Handles menu

 

The Handles menu is a convenient way to allocate and free Win32 resource handles and track the events in Memory Validator.

 

Leaks are created by creating but not freeing each type of resource below.

 

The thread creation and thread deletion examples can test the detection of cross thread allocation.

 

 

example-app-handles1

 

Start a thread and allocate some memory in it to be deallocated below

Stop the thread

The deallocation will happen from a different thread to the one that allocated.

example-app-handles2

Allocate a device context

Deallocate it

example-app-handles3

Get a device context using GetDC()

Release it using ReleaseDC()

example-app-handles4

Open a file. If the file is not closed the file handle will be leaked.

Close it

example-app-handles5

Create a font

Destroy it

example-app-handles6

Create a pen

Destroy it

example-app-handles7

Create a brush

Destroy it

example-app-handles8

Create an icon

Destroy it

example-app-handles9

Create a mouse cursor

Destroy it

example-app-handles10

Create a window

Destroy it

example-app-handles11

Create a bitmap

Destroy it

example-app-handles12

Extract an icon from a bitmap

Destroy the icon

example-app-handles13

Test the lifetime of a temporary CDC object

example-app-handles14

Map a view of a file into memory

Unmap the view

example-app-handles15

Create some regions using CreateRectRgn(),one of which leaks

See CTeststakView::OnRegionTests()

 

 

 

The More Handles menu

 

The More Handles menu is...well, more of the same - i.e. convenient ways to create different types of handles and oberve the events in Memory Validator.

 

 

example-app-more-handles

 

Create some Timer Queue and Timer handles - see CTeststakView::OnTimerQueueTests()

 

Create and MFC CFile object, write to it and then close it.