Dispose of each object when your done using it. This is what the ability to explicitly release managed resources is for.
stream.Dispose();
If you are already disposing of the objects, does disposing the device, or whatever has the reference to your stream, actually free
up the memory while the application is still running?
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Big D" <(E-Mail Removed)> wrote in message news:Xns96DE62975BF84supagoatatverizonDne@216.196.97.142...
> I'm trying to write a game in c# using managed direct3d, and I have a bit
> of a situation. I'm using sprites to draw my 2d graphics, and I'm
> generating some of my sprites dynamically by writing to Bitmaps, then
> saving the Bitmaps to a MemoryStream that I load as a texture using
> Device.FromStream.
>
> My problem is that using this method seems to cause a memory leak over
> repeated calls to FromStream. It looks to me like when I call FromStream,
> Direct3D keeps a reference to my stream so it doesn't get GC'd.
>
> I've tried re-using the same MemoryStream and setting the Position to 0
> each time, and I've tried using a new MemoryStream each time.
>
> I'm using a somewhat old version of DX9, so maybe (hopefully?) it's fixed
> now, but I wanted to know if anyone could give any advice or tell me if
> this was a known issue.
>
> Thanks!