From fb89690166fa54ff1e3d0f9987e78d914c7d8a50 Mon Sep 17 00:00:00 2001 From: wj32 Date: Sat, 17 Oct 2009 11:53:08 +0000 Subject: [PATCH] 1/4 stack -> 1/16 stack git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2249 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker.Common/Utils.cs | 6 ++++++ trunk/ProcessHacker.Common/WorkQueue.cs | 2 +- trunk/ProcessHacker/Forms/HackerWindow.cs | 4 ++-- trunk/ProcessHacker/Forms/IPInfoWindow.cs | 6 +++--- trunk/ProcessHacker/Forms/ResultsWindow.cs | 2 +- trunk/ProcessHacker/Program/Program.cs | 8 ++++---- trunk/ProcessHacker/UI/Async/AsyncUtils.cs | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/trunk/ProcessHacker.Common/Utils.cs b/trunk/ProcessHacker.Common/Utils.cs index a28dee909..9d7d8a424 100644 --- a/trunk/ProcessHacker.Common/Utils.cs +++ b/trunk/ProcessHacker.Common/Utils.cs @@ -42,6 +42,12 @@ namespace ProcessHacker.Common #region Constants + public const int OneStackSize = 1024 * 1024; + public const int HalfStackSize = OneStackSize / 2; + public const int QuarterStackSize = HalfStackSize / 2; + public const int EighthStackSize = QuarterStackSize / 2; + public const int SixteenthStackSize = EighthStackSize / 2; + public static int[] Primes = { 3, 7, 11, 0x11, 0x17, 0x1d, 0x25, 0x2f, 0x3b, 0x47, 0x59, 0x6b, 0x83, 0xa3, 0xc5, 0xef, diff --git a/trunk/ProcessHacker.Common/WorkQueue.cs b/trunk/ProcessHacker.Common/WorkQueue.cs index 7843a1071..72b3ed009 100644 --- a/trunk/ProcessHacker.Common/WorkQueue.cs +++ b/trunk/ProcessHacker.Common/WorkQueue.cs @@ -358,7 +358,7 @@ namespace ProcessHacker.Common /// private void CreateWorkerThread() { - Thread workThread = new Thread(this.WorkerThreadStart); + Thread workThread = new Thread(this.WorkerThreadStart, Utils.SixteenthStackSize); workThread.IsBackground = true; workThread.Priority = ThreadPriority.Lowest; workThread.SetApartmentState(ApartmentState.STA); diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs index 92b780c7a..ed49311a1 100644 --- a/trunk/ProcessHacker/Forms/HackerWindow.cs +++ b/trunk/ProcessHacker/Forms/HackerWindow.cs @@ -350,7 +350,7 @@ namespace ProcessHacker SysInfoWindow = new SysInfoWindow(); Application.Run(SysInfoWindow); - }); + }, Utils.SixteenthStackSize); sysInfoThread.Start(); } else @@ -2727,7 +2727,7 @@ namespace ProcessHacker { Updater.Update(this, interactive); this.Invoke(new MethodInvoker(() => checkForUpdatesMenuItem.Enabled = true)); - })); + }), Utils.SixteenthStackSize); t.IsBackground = true; t.Start(); } diff --git a/trunk/ProcessHacker/Forms/IPInfoWindow.cs b/trunk/ProcessHacker/Forms/IPInfoWindow.cs index 7647eeb65..ccb9df110 100644 --- a/trunk/ProcessHacker/Forms/IPInfoWindow.cs +++ b/trunk/ProcessHacker/Forms/IPInfoWindow.cs @@ -66,7 +66,7 @@ namespace ProcessHacker if (_ipAction == IpAction.Whois) { - t = new Thread(new ParameterizedThreadStart(Whois)); + t = new Thread(new ParameterizedThreadStart(Whois), Utils.SixteenthStackSize); labelInfo.Text = "Whois host infomation for address: " + _ipAddress.ToString(); labelStatus.Text = "Checking..."; listInfo.Columns.Add("Results"); @@ -74,7 +74,7 @@ namespace ProcessHacker } else if (_ipAction == IpAction.Tracert) { - t = new Thread(new ParameterizedThreadStart(Tracert)); + t = new Thread(new ParameterizedThreadStart(Tracert), Utils.SixteenthStackSize); labelStatus.Text = "Tracing route..."; listInfo.Columns.Add("Count"); listInfo.Columns.Add("Reply Time"); @@ -84,7 +84,7 @@ namespace ProcessHacker } else if (_ipAction == IpAction.Ping) { - t = new Thread(new ParameterizedThreadStart(Ping)); + t = new Thread(new ParameterizedThreadStart(Ping), Utils.SixteenthStackSize); labelStatus.Text = "Pinging..."; listInfo.Columns.Add("Results"); ColumnSettings.LoadSettings(Settings.Instance.IPInfoPingListViewColumns, listInfo); diff --git a/trunk/ProcessHacker/Forms/ResultsWindow.cs b/trunk/ProcessHacker/Forms/ResultsWindow.cs index 65c65be60..dfe29fd95 100644 --- a/trunk/ProcessHacker/Forms/ResultsWindow.cs +++ b/trunk/ProcessHacker/Forms/ResultsWindow.cs @@ -184,7 +184,7 @@ namespace ProcessHacker _so.Searcher.SearchProgressChanged += new SearchProgressChanged(Searcher_SearchProgressChanged); _so.Searcher.SearchError += new SearchError(SearchError); - _searchThread = new Thread(new ThreadStart(_so.Searcher.Search)); + _searchThread = new Thread(new ThreadStart(_so.Searcher.Search), Utils.SixteenthStackSize); _searchThread.Start(); } diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 60f75293d..307c9a509 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -1091,7 +1091,7 @@ namespace ProcessHacker Application.Run(ed); Program.MemoryEditorsThreads.Remove(id); - })); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1141,7 +1141,7 @@ namespace ProcessHacker Application.Run(rw); Program.ResultsThreads.Remove(id); - })); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1198,7 +1198,7 @@ namespace ProcessHacker Application.Run(pw); Program.PEThreads.Remove(path); - })); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1254,7 +1254,7 @@ namespace ProcessHacker Application.Run(pw); Program.PThreads.Remove(process.Pid); - })); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); diff --git a/trunk/ProcessHacker/UI/Async/AsyncUtils.cs b/trunk/ProcessHacker/UI/Async/AsyncUtils.cs index 7cca0b4c3..720a39963 100644 --- a/trunk/ProcessHacker/UI/Async/AsyncUtils.cs +++ b/trunk/ProcessHacker/UI/Async/AsyncUtils.cs @@ -59,7 +59,7 @@ namespace ProcessHacker.FormHelper isRunning = true; } - _asyncThread = new Thread(InternalStart); + _asyncThread = new Thread(InternalStart, ProcessHacker.Common.Utils.SixteenthStackSize); _asyncThread.Start(); }