CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2013

    Threads with OutOfMemoryException

    public static void Thread(object state)
        byte[] bytes = new byte[64000000];
    In the following code I'm getting an OutOfMemoryException because I'm launching these threads 1024 times and only some of them gives me an exception.

    I can't reduce the size of the chunk, its a mandatory requisite that I have a chunk of 64MB.

    What can I do to fix this?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: Threads with OutOfMemoryException

    Quote Originally Posted by whellman View Post
    What can I do to fix this?
    Change your design.

  3. #3
    Join Date
    Feb 2011
    United States

    Re: Threads with OutOfMemoryException

    You can't allocate 64 GB in a single process. I think the per-process limit is 2 GB (or, possibly, 3 GB) per process (all threads are under a single process).
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.