Out of Memory exception


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Out of Memory exception

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Out of Memory exception

    I want to add images in a panel. Each image size is 5 to 6 MB. If I add more than 35 images then it shows error that "Out of Memory". This exceptions occur when Image.FromFile(string) is executed. If less than 35 images is loaded then no error shows.
    Code:
    if (DialogResult.OK == ofdLoadFromHDD.ShowDialog())
    {
    
    string[] strArray = ofdLoadFromHDD.FileNames;
    int count = strArray.Count();
    DynamicGroupBox objDGB = new DynamicGroupBox(scrolledValue);
    GroupBox gB = new GroupBox();
    
    try
    {
    for (int i = 0; i < count; i++)
    {
    Bitmap bmp = (Bitmap)Image.FromFile(strArray[i]);
    
    CommonInformation.SCANNING_NUMBER++;
    objCommonUtility.replaceImageIntoDB(bmp, CommonInformation.SCANNING_NUMBER.ToString());
    
    gB = objDGB.createGroupBox(bmp, CommonInformation.SCANNING_NUMBER, false);
    
    pnlImageContainer.Controls.Add(gB);
    
    }
    gB.Select();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    CommonInformation.SCANNING_NUMBER--;
    }
    }
    Development Environment:
    Windows XP Professional Edition
    VS 2010, C#, .NET framework 4.0

    How can I solve this problem?
    Last edited by Hack; 12-13-2011 at 07:10 AM. Reason: Added Code Tags

Similar Threads

  1. Replies: 1
    Last Post: 04-21-2008, 02:28 PM
  2. Replies: 2
    Last Post: 08-23-2007, 10:09 AM
  3. Out of memory exception frequently
    By j2ee_raj in forum Java
    Replies: 0
    Last Post: 09-28-2006, 10:32 AM
  4. Out of memory exception on the web server
    By smallikas in forum ASP.NET
    Replies: 0
    Last Post: 05-26-2005, 06:00 AM
  5. help memory
    By kathy in forum Java
    Replies: 0
    Last Post: 11-02-2001, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center