Using stream without using memory
-
I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?
-
I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?
No. Everything you do requires memory. The CPU performs operations on stored memory, (usually in registers), not from disk. Without some kind of hardware gizmo you cannot do things without moving the data through memory. Just manage your memory carefully. Ensure that once the image has been sent to the client, it is removed from local memory.
Simon
-
I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?