Running out of memory when getting a bitmap from a server?
Posted
by ikky
on Stack Overflow
See other posts from Stack Overflow
or by ikky
Published on 2010-04-14T11:54:53Z
Indexed on
2010/04/14
12:03 UTC
Read the original article
Hit count: 174
Hi! I'm making an application which uses MANY images. The application gets the images from a server, and downloads them one at a time. After many images the creation of a bitmap returns an exception, but i don't know how to solve this. Here is my function for downloading the images:
public static Bitmap getImageFromWholeURL(String sURL)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(sURL);
myRequest.Method = "GET";
// If it does not exist anything on the url, then return null
try
{
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
myResponse.Close();
return bmp;
}
catch (Exception e)
{
return null;
}
}
Can anyone help me out here? Thanks in advance!
© Stack Overflow or respective owner