CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    OutOfMemoryException when allocation large memory blocks

    Dear Softwaredevelopers,

    In my application I have to allocate a huge amount of memory but the following C# console programm creates an OutOfMemoryException when I try to allocate memory >512 MB. and I wonder why.

    My System:
    Intel Core2 Quad CPU 3GB
    Windows XP 32-Bit
    Visual Studio 2008
    available free memory 2.3GB

    Can anybody help?

    Greetings Christian


    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace MemoryAllocation
    {
    class Program
    {
    static void Main(string[] args)
    {
    int size = 2;

    while (size > 0)
    {
    Byte[] b = new Byte[size];

    for (int i = 0; i<size; ++i)
    b[i] = 13;
    size *= 2;
    }

    }
    }
    }
    Attached Images Attached Images

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured