开发者

BSoD when creating threads

I am trying to create +5 threads synchronously so there shouldn't be any concurrency error.

Code:

System.Threading.Thread t = new System.Threading.Thread(proc);
t.Start();//==t.BlueScreen();
t.Join();

Is darkness a feature ?

I am doing something wrong?

OS:Microsoft windows vista(unfortunately) x64

Language:C# 3.0|4.0

.Net version:3.5|4

edit:

Personel[] spersonel;

proc:

void proc()
{
    spersonel = Personel.GetRows(GetThreadSafeDataConnection());
}

Personel:

   internal static Personel[] GetRows(System.Data.SqlClient.SqlConnection Connection)
        {
            int i = 0;
            int c = SomeOtherGODClass.Val_int(SomeGODClass.ExecuteScalar("Select Count(*) from Personel", Connection).ToStrin开发者_JAVA百科g());
            Personel[] Rs = new Personel[c];
            System.Data.SqlClient.SqlDataReader sdr = SomeGODClass.ExecuteReader("Select * from Personel", Connection);
            while (sdr.Read()) Rs[i++] = new Personel(sdr);
            sdr.Close();
            if (Rs.Length > 1) mergeSort(ref Rs);
            return Rs;
        }


The code snippet you pasted looks fine, but doesn't really tell us much. It would be helpful to paste contents of proc, and provide us a larger scope of what your program is doing.

It might also be helpful to paste as much of the contents of the BSoD as possible, including why it occurred (access violation, etc). Although not directly helpful, it would provide some clues.


Your error code is not a typical BSOD code. It is STATUS_PAGEFILE_QUOTA, "The pagefile quota for the process has been exhausted."

Getting this on a 64-bit version of Windows is possible. 64-bit programs cannot run out of memory, they've got 16 terabytes of virtual memory. They run out of mappable memory pages first. The operating system sets an upper limit to how much of the paging file size a program can hog. You exceeded it. If it is really a BSOD then it probably ran out of kernel memory pool space, each thread you create needs about 24 KB of memory for the kernel stack.

I have to guess that your program is creating way too many threads. Keep any eye on the Threads column in Taskmgr.exe, Processes tab. The Performance tab shows what's happening to the kernel memory pool.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜