From 2d62ded1aa92b82d696fb37c952732ae1a309011 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 10 Jan 2007 03:26:22 +0000 Subject: Reduced allocated stack sizes. Trims about 13MB of memory consumption. git-svn-id: svn://localhost/ardour2/trunk@1293 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/pthread_utils.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libs/pbd/pthread_utils.cc') diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index db242cea7b..3408f2c0b7 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -43,6 +43,16 @@ pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, { int ret; + pthread_attr_t default_attr; + bool use_default_attr = (attr == NULL); + + if (use_default_attr) { + // set default stack size to sensible default for memlocking + pthread_attr_init(&default_attr); + pthread_attr_setstacksize(&default_attr, 500000); + attr = &default_attr; + } + if ((ret = pthread_create (thread, attr, start_routine, arg)) == 0) { std::pair newpair; newpair.first = name; @@ -53,6 +63,10 @@ pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, pthread_mutex_unlock (&thread_map_lock); } + + if (use_default_attr) { + pthread_attr_destroy(&default_attr); + } return ret; } -- cgit v1.2.3