Running out of memory when getting a bitmap from a server?
- by ikky
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!