FIX: Memory Leak in OpenClusterNode() Function Call

ID: Q207576


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK)
  • Microsoft Cluster Server


SYMPTOMS

OpenClusterNode leaks 528 bytes of memory each time it is called. Closing the handle does not release the memory. Restarting the application releases the memory.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

This problem was corrected in Windows NT 4.0 Service Pack 4.


MORE INFORMATION

To compile the code in Visual C++ 6.0:

  1. Create a default Win32 Console application named "OpenNode".


  2. On the Project menu, click Settings, click the Link tab, and then add the file Clusapi.lib.


  3. Paste the following code into the .cpp file:


  4. 
    #include "stdafx.h"
    #include <windows.h>
    #include <clusapi.h>
    #include <stdlib.h>
    
    int main(int argc, char* argv[])
    {
    	HCLUSTER hCluster;
    	HNODE hNode;
    	WCHAR lpwBuffer[100];
    	DWORD dwcbSize;
    	int iCount;
    	int iMaxCount = 100000;
    
    	if( argc > 1 )
    	{
    		iMaxCount = atoi( argv[1] );
    
    		if( -1 == iMaxCount )
    		{
    			Sleep( 10000 );
    			return 0;
    		}
    	}
    
    	dwcbSize = 100;
    	if( GetComputerNameW( lpwBuffer, &dwcbSize ) )
    	{
    		wprintf( L"Local node name: %s\n", lpwBuffer );
    
    		hCluster = OpenCluster( NULL );
    
    		if( NULL == hCluster )
    		{
    			wprintf( L"Unable to open cluster.\n" );
    		}
    		else
    		{ 
    			hNode = OpenClusterNode( hCluster, lpwBuffer );
    			
    			for( iCount = 0; NULL != hNode && iCount < iMaxCount; iCount++ )
    			{
    				CloseClusterNode( hNode );
    				hNode = OpenClusterNode( hCluster, lpwBuffer );
    			}
    
    			if( NULL != hNode )
    			{
    				CloseClusterNode( hNode );
    			}
    
    			wprintf( L"Performed %d iterations.\n", iCount );
    			CloseCluster( hCluster );
    		}
    
    	}
    	else
    	{ 
    		wprintf( L"Unable to get computer name.\n");
    	}
    
    	return 0;
    } 

To Reproduce This Problem on a Service Pack 3 (SP3) Cluster

  1. Start Performance Monitor (Perfmon).


  2. Start a command window. From the OpenNode debug directory, run Open -1. This action pauses the application for 10 seconds.


  3. In Perfmon, click Edit, and then click Add To Chart. In the Add To Chart dialog box, select Process for Object, select Working Set for Counter, and select OpenNode for Instance. Click Add.


  4. Wait until OpenNode has completed executing.


  5. Run OpenNode again. You should see the working set for OpenNode steadily climbing.


Additional query words:

Keywords : kbcluster
Version : WINDOWS:; winnt:
Platform : WINDOWS winnt
Issue type : kbbug


Last Reviewed: January 5, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.