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
    Posts
    1

    Threads with OutOfMemoryException

    Code:
    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 / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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
    Location
    United States
    Posts
    1,016

    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,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    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
  •  





Click Here to Expand Forum to Full Width

Featured