Discussion:
How to delete unmanaged memory?
(too old to reply)
Tim Johnson
2004-10-17 21:59:57 UTC
Permalink
I'm using a MessageWindow in C# to get a pointer to some data from a legacy
C++ dll. I can decipher the msg.LParam with the Marshal methods and stash
the value away in my local variables. But how can I then delete the memory
associated with LParam, which was allocated by the C++ code before he did a
PostMessage to me? The Marshal class in CF does not seem to support the
usual memory management functions.
--
Tim Johnson
High Point Software
www.high-point.com
(503) 312-8625
Chris Tacke, eMVP
2004-10-18 00:19:57 UTC
Permalink
You can P/Invoke any API for memory management, though I'm not certain that
allocating in an unmanaged component and then freeing in a managed component
is a good idea. You should call back to the unmanaged component and tell it
to free what it allocated.

-Chris
Post by Tim Johnson
I'm using a MessageWindow in C# to get a pointer to some data from a legacy
C++ dll. I can decipher the msg.LParam with the Marshal methods and stash
the value away in my local variables. But how can I then delete the memory
associated with LParam, which was allocated by the C++ code before he did a
PostMessage to me? The Marshal class in CF does not seem to support the
usual memory management functions.
--
Tim Johnson
High Point Software
www.high-point.com
(503) 312-8625
Loading...