Exemple #1
0
        //
        // Invoke a kernel heap out of memory condition by creating
        // lots of kernel objects
        //
        public void KernelOOMTest()
        {
            IdleThread[] threads;

            int threadCount = 1000;

            while (true)
            {
                System.Console.WriteLine("Creating {0} threads", threadCount);

                threads = new IdleThread[threadCount];
                if (threads == null)
                {
                    System.Console.WriteLine("Error allocating Thread[]");
                    return;
                }

                for (int i = 0; i < threadCount; i++)
                {
                    threads[i] = new IdleThread(i);
                    if (threads[i] == null)
                    {
                        System.Console.WriteLine("Error creating thread");
                        return;
                    }
                }

                // Start them running
                for (int i = 0; i < threadCount; i++)
                {
                    ((!)threads[i]).RunThread();
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Stops monitoring for idle activity.
 /// </summary>
 public static void StopMonitoring()
 {
     if (!IsMonitoring)
     {
         throw new InvalidOperationException("The IdleManager is not monitoring.");
     }
     IsMonitoring = false;
     IdleThread.Join();
 }