This method 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 current socket handle. This
value only reflects the amount of memory explicitly allocated by this
class 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 method forces the current thread into a locked state, and all
network operations will block until the method returns. Because this
method 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 method 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 method 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.