±
±I?@aI!iac????!j
Hi there,
C++ declaration:
void __stdcall VfwDecoder_GetOutputBitmapInfoHeader(HANDLE hVfwDecoder,
BITMAPINFOHEADER** ppBmh)
{
CVideoDecompress *pVideoDecompress = (CVideoDecompress*)hVfwDecoder;
if (pVideoDecompress != NULL )
*ppBmh = pVideoDecompress->GetOutputBitmapInfoHeader();
}
C# declaration:
[DllImport("VfwDecoder.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr VfwDecoder_DecompressNative(IntPtr hVfwDecoder,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)] byte[]
CompressedData, uint dwSize);
Using:
BITMAPINFOHEADER bmpHeader = new BITMAPINFOHEADER();
VfwDecoderLib.VfwDecoder_GetOutputBitmapInfoHeader(m_hVfwDecoder, ref
bmpHeader);
When I using this code, the program is memory leak as the virtual memory is
growing. I know bmpHeader is not necessary to new BITMAPINFOHEADER() since
the native C++ function return the BITMAPINFOHEADER pointer to the caller.
But from my understanding, C# will garbarge collect the unused
BITMAPINFOHEADER object and prevent memory leak. Could anyone tell me why
there is memory leak?
Thanks a lot.
C++ declaration:
void __stdcall VfwDecoder_GetOutputBitmapInfoHeader(HANDLE hVfwDecoder,
BITMAPINFOHEADER** ppBmh)
{
CVideoDecompress *pVideoDecompress = (CVideoDecompress*)hVfwDecoder;
if (pVideoDecompress != NULL )
*ppBmh = pVideoDecompress->GetOutputBitmapInfoHeader();
}
C# declaration:
[DllImport("VfwDecoder.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr VfwDecoder_DecompressNative(IntPtr hVfwDecoder,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)] byte[]
CompressedData, uint dwSize);
Using:
BITMAPINFOHEADER bmpHeader = new BITMAPINFOHEADER();
VfwDecoderLib.VfwDecoder_GetOutputBitmapInfoHeader(m_hVfwDecoder, ref
bmpHeader);
When I using this code, the program is memory leak as the virtual memory is
growing. I know bmpHeader is not necessary to new BITMAPINFOHEADER() since
the native C++ function return the BITMAPINFOHEADER pointer to the caller.
But from my understanding, C# will garbarge collect the unused
BITMAPINFOHEADER object and prevent memory leak. Could anyone tell me why
there is memory leak?
Thanks a lot.