InetGetMemoryUsage Function  
 
BOOL WINAPI InetGetMemoryUsage(
  SOCKET hSocket,  
  ULARGE_INTEGER *lpMemUsage  
);

Return the amount of memory allocated for the network connection.

Parameters

hSocket
The socket handle.
lpMemUsage
A pointer to a ULARGE_INTEGER variable which will specify how much memory has been allocated for the socket. This parameter will be initialized to a value of zero by the function and updated with the total number of bytes allocated.

Return Value

If the function succeeds, the return value is non-zero and the memory usage value will be updated. If the socket handle does not specific a socket created by the library, the return value is zero. Call the InetGetLastError function to determine the cause of the failure.

Remarks

This function returns the amount of memory allocated for the socket. It enumerates all heap allocations made by the process and returns the total number of bytes allocated for the specific socket handle. If the hSocket parameter value is INVALID_SOCKET, the function will calculate the amount of memory allocated for all sockets created by the library. This value only reflects the amount of memory explicitly allocated by this library and does not reflect the total working set size of the process, or memory allocated by any other libraries. To determine the working set size for the process, refer to the Win32 GetProcessWorkingSetSize and GetProcessMemoryInfo functions.

This function forces the current thread into a locked state, and all network operations will block until the function returns. Because this function enumerates all heaps created for the process, it can be an expensive operation, particularly when a large number of connections have been established. Frequent use of this function can significantly degrade the performance of the application. It is primarily intended for use as a debugging tool to determine if memory usage is the result of an increase in active network connections. If the value returned by the function remains reasonably constant, but the amount of memory allocated for the process continues to grow, it could indicate a memory leak in some other area of the application.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cswsock11.h
Import Library: cswskv11.lib

See Also

InetGetServerStackSize, InetSetServerStackSize