Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Decrease the stack size so that we use even less virtual memory now; …

…do not use less stack than is allowed by the platform. Fixes issue #188.
  • Loading branch information...
commit c2da36e3338a48452d2826e2bb267eeb1e363bdc 1 parent 84df22a
@FooBarWidget FooBarWidget authored
View
2  ext/common/ApplicationPoolServerExecutable.cpp
@@ -266,7 +266,7 @@ class Server {
*/
class Client {
private:
- static const int CLIENT_THREAD_STACK_SIZE = 1024 * 128;
+ static const int CLIENT_THREAD_STACK_SIZE = 1024 * 64;
/** The Server that this Client object belongs to. */
Server &server;
View
2  ext/common/StandardApplicationPool.h
@@ -104,7 +104,7 @@ class StandardApplicationPool: public ApplicationPool {
static const int DEFAULT_MAX_IDLE_TIME = 120;
static const int DEFAULT_MAX_POOL_SIZE = 20;
static const int DEFAULT_MAX_INSTANCES_PER_APP = 0;
- static const int CLEANER_THREAD_STACK_SIZE = 1024 * 128;
+ static const int CLEANER_THREAD_STACK_SIZE = 1024 * 64;
static const unsigned int MAX_GET_ATTEMPTS = 10;
static const unsigned int GET_TIMEOUT = 5000; // In milliseconds.
View
2  ext/nginx/HelperServer.cpp
@@ -139,7 +139,7 @@ struct ClientDisconnectedException { };
class Client {
private:
/** The client thread stack size in bytes. */
- static const int CLIENT_THREAD_STACK_SIZE = 1024 * 128;
+ static const int CLIENT_THREAD_STACK_SIZE = 1024 * 64;
/** The client number for this Client object, assigned by Server. */
unsigned int number;
View
17 ext/oxt/thread.hpp
@@ -34,6 +34,7 @@
#ifdef OXT_BACKTRACE_IS_ENABLED
#include <sstream>
#endif
+#include <limits.h> // for PTHREAD_STACK_MIN
namespace oxt {
@@ -108,6 +109,15 @@ class thread: public boost::thread {
public:
/**
+ * The platform's minimum stack size, in bytes.
+ */
+ #if defined(PTHREAD_STACK_MIN)
+ static const unsigned int MIN_STACK_SIZE = PTHREAD_STACK_MIN;
+ #else
+ static const unsigned int MIN_STACK_SIZE = 1024 * 128;
+ #endif
+
+ /**
* Create a new thread.
*
* @param func A function object which will be called as the thread's
@@ -118,7 +128,9 @@ class thread: public boost::thread {
* a name will be automatically chosen.
* @param stack_size The stack size, in bytes, that the thread should
* have. If 0 is specified, the operating system's default stack
- * size is used.
+ * size is used. If non-zero is specified, and the size is smaller
+ * than the operating system's minimum stack size, then the operating
+ * system's minimum stack size will be used.
* @pre func must be copyable.
* @throws boost::thread_resource_error Something went wrong during
* creation of the thread.
@@ -127,6 +139,9 @@ class thread: public boost::thread {
initialize_data(name);
set_thread_main_function(boost::bind(thread_main, func, data));
+ if (stack_size < MIN_STACK_SIZE) {
+ stack_size = MIN_STACK_SIZE;
+ }
start_thread(stack_size);
}
Please sign in to comment.
Something went wrong with that request. Please try again.