A
Andrew Falanga
Hi,
I'm going through a link provided to me from someone here earlier
about implementing the IDisposable interface on factory patterned
objects. In the document from MSDN I'm seeing this comment in the
Dispose( ) function:
// Set large fields to null.
Is this something as simple as this (an example):
byte[] byteArray = new byte[/*some really large number*/];
byteArray = null;
Ultimately, this question has to do with how to release a large amount
of memory. I'm working graphic images and one class needs to work
with PNM, or PPM, graphics. There isn't anything in GDI+ that handles
this type natively so I've implemented it myself.
Since implementing IDisposable I'd like to know about how I can grab
enough memory to load the graphic data into memory, similar to a
Bitmap object, and then, like the Bitmap, call Dispose( ) on my object
and watch the memory drop. From my C++ experience I would do this by
freeing a pointer. However, I don't know how to hold onto a valid
pointer reference outside of unsafe code, and I'd need to for this to
work. So, how do I allocate enough memory to hold the graphic data in
memory and then release with a call to Dispose( ) when I want to?
Thanks,
Andy
I'm going through a link provided to me from someone here earlier
about implementing the IDisposable interface on factory patterned
objects. In the document from MSDN I'm seeing this comment in the
Dispose( ) function:
// Set large fields to null.
Is this something as simple as this (an example):
byte[] byteArray = new byte[/*some really large number*/];
byteArray = null;
Ultimately, this question has to do with how to release a large amount
of memory. I'm working graphic images and one class needs to work
with PNM, or PPM, graphics. There isn't anything in GDI+ that handles
this type natively so I've implemented it myself.
Since implementing IDisposable I'd like to know about how I can grab
enough memory to load the graphic data into memory, similar to a
Bitmap object, and then, like the Bitmap, call Dispose( ) on my object
and watch the memory drop. From my C++ experience I would do this by
freeing a pointer. However, I don't know how to hold onto a valid
pointer reference outside of unsafe code, and I'd need to for this to
work. So, how do I allocate enough memory to hold the graphic data in
memory and then release with a call to Dispose( ) when I want to?
Thanks,
Andy