P
PBS Productions
Hi,
I hope someone can help with this one. I'm using below function but it
is leaking memory although an article on MSDN says it should not leak
memory.
Dim TopHandle As Integer
TopHandle = GetForegroundWindow()
Dim buffer() As Byte
Dim buffersize As Integer = 250
Dim p As IntPtr = LocalAlloc(&H40, buffersize)
GetWindowText(TopHandle, p, buffersize)
Dim w As String
// Take away below line and the memory leak is gone
w = System.Runtime.InteropServices.Marshal.PtrToStringUni(p)
LocalFree(p)
The marshal function is causing the memory leak. What am I doing
wrong?
Thanks,
Jo.
I hope someone can help with this one. I'm using below function but it
is leaking memory although an article on MSDN says it should not leak
memory.
Dim TopHandle As Integer
TopHandle = GetForegroundWindow()
Dim buffer() As Byte
Dim buffersize As Integer = 250
Dim p As IntPtr = LocalAlloc(&H40, buffersize)
GetWindowText(TopHandle, p, buffersize)
Dim w As String
// Take away below line and the memory leak is gone
w = System.Runtime.InteropServices.Marshal.PtrToStringUni(p)
LocalFree(p)
The marshal function is causing the memory leak. What am I doing
wrong?
Thanks,
Jo.