I'm allocating a block of memory in C# to retrieve information from an unmanaged data buffer:
handle = Marshal.AllocHGlobal(33455);
The maximum size of the information retrieved is 33,455 bytes, but the size of the information may be smaller than that in some cases.
How can I determine how many bytes are actually being used in the allocated block, rather than how many are actually allocated?