diff --git a/.hgtags b/.hgtags
index 68d1bdaf310f41faf8e54e14ab2fe6bf928b2905..319a7c242534d4ec16808a8f0bde22bc34bed744 100755
--- a/.hgtags
+++ b/.hgtags
@@ -69,6 +69,7 @@ b53a0576eec80614d7767ed72b40ed67aeff27c9 DRTVWR-38_2.5.2-release
 4e9eec6a347f89b2b3f295beb72f1cf7837dff66 2.6.0-start
 9283d6d1d7eb71dfe4c330e7c9144857e7356bde 2.6.0-beta1
 9283d6d1d7eb71dfe4c330e7c9144857e7356bde DRTVWR-40_2.6.0-beta1
+461c8c65b5c799ddfe365422f9be9c0095d91e7d 2.6.0-beta1-tip
 9e4641f4a7870c0f565a25a2971368d5a29516a1 2.6.0-beta2
 9e4641f4a7870c0f565a25a2971368d5a29516a1 DRTVWR-41_2.6.0-beta2
 42f32494bac475d0737799346f6831558ae8bf5d 2.6.0-release
@@ -318,5 +319,14 @@ ceed0b65a69f1eac20d523e0203320a32f9a3f3c DRTVWR-215
 97977c67245f52db20eb15f1918cc0f24778cabc 3.4.0-release
 5adb2b8f96c3cac88ad7c7d996d707f1b29df336 3.4.1-beta1
 b3f74858a1c8720c82d0978f3877a3fc8ba459ec 3.4.1-beta1a
-45028c687415ae2d6ca0c13fefca62cba60e013f DRTVWR-179
 b61afe175b829c149d369524a4e974dfda99facf DRTVWR-219
+2b779f233ee6f38c89cb921650c773a96e63da92 DRTVWR-220
+0b9d95f4bfb6867cbf56eaec51633b0da2f1262d DRTVWR-221
+e6e553761829dc0270eaaa712b7cb0622535b076 3.4.1-beta3
+f00068a66a2e2f72acbe3f690b98b323e740b289 DRTVWR-222
+305950187c628a5d6743ee9ea711cc5b9177a18e 3.4.1-beta4
+dd23d4da3bcb2ffda58569e759feb7c119982973 DRTVWR-224
+0bd3744ff060452aa13ff4992eafb381df7b1012 3.4.1-beta5
+29075f8c1abed53dcf195a59f61744e27a91108f DRTVWR-226
+fba99f381b8d4ad1b7b42fa4993b29998d95be18 DRTVWR-179
+49ed253c80bed7410e238eeab35a9f14cb034364 3.4.1-beta6
diff --git a/autobuild.xml b/autobuild.xml
index a86c8fd866b9f71dfd668ad1a3c1774ffd208738..05e0ac28aef6940f09acf2648eeb82d30a8b3111 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -1770,9 +1770,9 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>dde928cb24d22a267004a8c17669ba65</string>
+              <string>8aedfdcf670348c18a9991ae1b384a61</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/226426/arch/Linux/installer/google_perftools-1.7-linux-20110412.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/262672/arch/Linux/installer/gperftools-2.0-linux-20120727.tar.bz2</string>
             </map>
             <key>name</key>
             <string>linux</string>
@@ -1782,9 +1782,9 @@
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>8308f7bd68bb7083655753b7abe7225f</string>
+              <string>f62841804acb91e1309603a84f3f0ce8</string>
               <key>url</key>
-              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/226287/arch/CYGWIN/installer/google_perftools-1.7-windows-20110411.tar.bz2</string>
+              <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/262672/arch/CYGWIN/installer/gperftools-2.0-windows-20120727.tar.bz2</string>
             </map>
             <key>name</key>
             <string>windows</string>
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index ed192a9975125106a8ffafb4d1f72b84d59f0917..ca258900c7f5d462f34d8b3b8ec4bed49dfa8b02 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -289,6 +289,7 @@ void LLApp::setupErrorHandling()
 	// occasionally checks to see if the app is in an error state, and sees if it needs to be run.
 
 #if LL_WINDOWS
+#if LL_SEND_CRASH_REPORTS
 	// This sets a callback to handle w32 signals to the console window.
 	// The viewer shouldn't be affected, sicne its a windowed app.
 	SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);
@@ -300,7 +301,7 @@ void LLApp::setupErrorHandling()
 		mExceptionHandler = new google_breakpad::ExceptionHandler(
 			L"C:\\Temp\\", 0, windows_post_minidump_callback, 0, google_breakpad::ExceptionHandler::HANDLER_ALL);
 	}
-
+#endif
 #else
 	//
 	// Start up signal handling.
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index f37e8459ffb92168240459c228a49f60e61f4edd..40cde485cffa672b38ea1ed85589447e7af0d1bf 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,6 +27,13 @@
 #define LLMEMORY_H
 
 #include "llmemtype.h"
+
+#if LL_WINDOWS && LL_DEBUG
+#define LL_CHECK_MEMORY llassert(_CrtCheckMemory());
+#else
+#define LL_CHECK_MEMORY
+#endif
+
 inline void* ll_aligned_malloc( size_t size, int align )
 {
 	void* mem = malloc( size + (align - 1) + sizeof(void*) );
@@ -90,7 +97,7 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r
 #else // USE_TCMALLOC
 // ll_aligned_foo_16 are not needed with tcmalloc
 #define ll_aligned_malloc_16 malloc
-#define ll_aligned_realloc_16 realloc
+#define ll_aligned_realloc_16(a,b,c) realloc(a,b)
 #define ll_aligned_free_16 free
 #endif // USE_TCMALLOC
 
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 1738c16dea4be7ef1ac72c80a0f4a01e9b3fdf48..abf47a0f57239b204459f9fa51fea631e81b1f21 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -134,8 +134,8 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms)
 		pending = getPending();
 		if(pending > 0)
 		{
-		unpause();
-	}
+			unpause();
+		}
 	}
 	else
 	{
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index a6ad6b125c1ad14cd1a9370f0713ed2159be655c..c2fbb544a88db36e1d7e850d9dd4231c17ef1490 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -114,7 +114,7 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
 		apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
 	}
 	mRunCondition = new LLCondition(mAPRPoolp);
-
+	mDataLock = new LLMutex(mAPRPoolp);
 	mLocalAPRFilePoolp = NULL ;
 }
 
@@ -173,7 +173,10 @@ void LLThread::shutdown()
 	}
 
 	delete mRunCondition;
-	mRunCondition = 0;
+	mRunCondition = NULL;
+
+	delete mDataLock;
+	mDataLock = NULL;
 	
 	if (mIsLocalPool && mAPRPoolp)
 	{
@@ -242,28 +245,30 @@ bool LLThread::runCondition(void)
 // Stop thread execution if requested until unpaused.
 void LLThread::checkPause()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 
 	// This is in a while loop because the pthread API allows for spurious wakeups.
 	while(shouldSleep())
 	{
+		mDataLock->unlock();
 		mRunCondition->wait(); // unlocks mRunCondition
+		mDataLock->lock();
 		// mRunCondition is locked when the thread wakes up
 	}
 	
- 	mRunCondition->unlock();
+ 	mDataLock->unlock();
 }
 
 //============================================================================
 
 void LLThread::setQuitting()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 	if (mStatus == RUNNING)
 	{
 		mStatus = QUITTING;
 	}
-	mRunCondition->unlock();
+	mDataLock->unlock();
 	wake();
 }
 
@@ -285,12 +290,12 @@ void LLThread::yield()
 
 void LLThread::wake()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 	if(!shouldSleep())
 	{
 		mRunCondition->signal();
 	}
-	mRunCondition->unlock();
+	mDataLock->unlock();
 }
 
 void LLThread::wakeLocked()
@@ -481,6 +486,19 @@ LLThreadSafeRefCount::LLThreadSafeRefCount() :
 {
 }
 
+LLThreadSafeRefCount::LLThreadSafeRefCount(const LLThreadSafeRefCount& src)
+{
+	if (sMutex)
+	{
+		sMutex->lock();
+	}
+	mRef = 0;
+	if (sMutex)
+	{
+		sMutex->unlock();
+	}
+}
+
 LLThreadSafeRefCount::~LLThreadSafeRefCount()
 { 
 	if (mRef != 0)
@@ -489,6 +507,7 @@ LLThreadSafeRefCount::~LLThreadSafeRefCount()
 	}
 }
 
+
 //============================================================================
 
 LLResponder::~LLResponder()
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index b52e70ab2ebcb637ac5fed388ba3b9ef285abb0e..115bf475532fa8f12720da5dcf6e9cded9fa7fad 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -97,6 +97,7 @@ class LL_COMMON_API LLThread
 protected:
 	std::string			mName;
 	LLCondition*		mRunCondition;
+	LLMutex*			mDataLock;
 
 	apr_thread_t		*mAPRThreadp;
 	apr_pool_t			*mAPRPoolp;
@@ -122,15 +123,15 @@ class LL_COMMON_API LLThread
 	inline void unlockData();
 	
 	// This is the predicate that decides whether the thread should sleep.  
-	// It should only be called with mRunCondition locked, since the virtual runCondition() function may need to access
+	// It should only be called with mDataLock locked, since the virtual runCondition() function may need to access
 	// data structures that are thread-unsafe.
 	bool shouldSleep(void) { return (mStatus == RUNNING) && (isPaused() || (!runCondition())); }
 
 	// To avoid spurious signals (and the associated context switches) when the condition may or may not have changed, you can do the following:
-	// mRunCondition->lock();
+	// mDataLock->lock();
 	// if(!shouldSleep())
 	//     mRunCondition->signal();
-	// mRunCondition->unlock();
+	// mDataLock->unlock();
 };
 
 //============================================================================
@@ -205,12 +206,12 @@ class LLMutexLock
 
 void LLThread::lockData()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 }
 
 void LLThread::unlockData()
 {
-	mRunCondition->unlock();
+	mDataLock->unlock();
 }
 
 
@@ -227,15 +228,27 @@ class LL_COMMON_API LLThreadSafeRefCount
 private:
 	static LLMutex* sMutex;
 
-private:
-	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
-	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
-
 protected:
 	virtual ~LLThreadSafeRefCount(); // use unref()
 	
 public:
 	LLThreadSafeRefCount();
+	LLThreadSafeRefCount(const LLThreadSafeRefCount&);
+	LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) 
+	{
+		if (sMutex)
+		{
+			sMutex->lock();
+		}
+		mRef = 0;
+		if (sMutex)
+		{
+			sMutex->unlock();
+		}
+		return *this;
+	}
+
+
 	
 	void ref()
 	{
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index b4ac984d57f7eb57212a9d43a2ec0e5d8f3da1f0..0d01dd0e3e72874dbd8171898ddbaa0afe364ff0 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -133,12 +133,12 @@ std::string LLCurl::getVersionString()
 //////////////////////////////////////////////////////////////////////////////
 
 LLCurl::Responder::Responder()
-	: mReferenceCount(0)
 {
 }
 
 LLCurl::Responder::~Responder()
 {
+	LL_CHECK_MEMORY
 }
 
 // virtual
@@ -202,23 +202,6 @@ void LLCurl::Responder::completedHeader(U32 status, const std::string& reason, c
 
 }
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p)
-	{
-		++p->mReferenceCount;
-	}
-	
-	void intrusive_ptr_release(LLCurl::Responder* p)
-	{
-		if (p && 0 == --p->mReferenceCount)
-		{
-			delete p;
-		}
-	}
-};
-
-
 //////////////////////////////////////////////////////////////////////////////
 
 std::set<CURL*> LLCurl::Easy::sFreeHandles;
@@ -267,15 +250,18 @@ void LLCurl::Easy::releaseEasyHandle(CURL* handle)
 	LLMutexLock lock(sHandleMutexp) ;
 	if (sActiveHandles.find(handle) != sActiveHandles.end())
 	{
+		LL_CHECK_MEMORY
 		sActiveHandles.erase(handle);
-
+		LL_CHECK_MEMORY
 		if(sFreeHandles.size() < MAX_NUM_FREE_HANDLES)
 		{
-		sFreeHandles.insert(handle);
-	}
-	else
-	{
+			sFreeHandles.insert(handle);
+			LL_CHECK_MEMORY
+		}
+		else
+		{
 			LLCurl::deleteEasyHandle(handle) ;
+			LL_CHECK_MEMORY
 		}
 	}
 	else
@@ -318,13 +304,15 @@ LLCurl::Easy::~Easy()
 	releaseEasyHandle(mCurlEasyHandle);
 	--gCurlEasyCount;
 	curl_slist_free_all(mHeaders);
+	LL_CHECK_MEMORY
 	for_each(mStrings.begin(), mStrings.end(), DeletePointerArray());
-
+	LL_CHECK_MEMORY
 	if (mResponder && LLCurl::sNotQuitting) //aborted
 	{	
 		std::string reason("Request timeout, aborted.") ;
 		mResponder->completedRaw(408, //HTTP_REQUEST_TIME_OUT, timeout, abort
 			reason, mChannels, mOutput);		
+		LL_CHECK_MEMORY
 	}
 	mResponder = NULL;
 }
@@ -599,35 +587,50 @@ void LLCurl::Multi::cleanup(bool deleted)
 	llassert_always(deleted || !mValid) ;
 
 	LLMutexLock lock(mDeletionMutexp);
-	
+
+
 	// Clean up active
 	for(easy_active_list_t::iterator iter = mEasyActiveList.begin();
 		iter != mEasyActiveList.end(); ++iter)
 	{
 		Easy* easy = *iter;
+		LL_CHECK_MEMORY
 		check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
-
+		LL_CHECK_MEMORY
 		if(deleted)
 		{
 			easy->mResponder = NULL ; //avoid triggering mResponder.
+			LL_CHECK_MEMORY
 		}
 		delete easy;
+		LL_CHECK_MEMORY
 	}
 	mEasyActiveList.clear();
 	mEasyActiveMap.clear();
 	
-	// Clean up freed
+	LL_CHECK_MEMORY
+	
+		// Clean up freed
 	for_each(mEasyFreeList.begin(), mEasyFreeList.end(), DeletePointer());	
 	mEasyFreeList.clear();
-
+	
+	LL_CHECK_MEMORY
+		
 	check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle));
 	mCurlMultiHandle = NULL ;
+
+	LL_CHECK_MEMORY
 	
 	delete mMutexp ;
 	mMutexp = NULL ;
+
+	LL_CHECK_MEMORY
+
 	delete mEasyMutexp ;
 	mEasyMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	mQueued = 0 ;
 	mState = STATE_COMPLETED;
 	
@@ -1104,6 +1107,7 @@ bool LLCurlRequest::getByteRange(const std::string& url,
 								 S32 offset, S32 length,
 								 LLCurl::ResponderPtr responder)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1131,6 +1135,7 @@ bool LLCurlRequest::post(const std::string& url,
 						 const LLSD& data,
 						 LLCurl::ResponderPtr responder, S32 time_out)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1158,6 +1163,7 @@ bool LLCurlRequest::post(const std::string& url,
 						 const std::string& data,
 						 LLCurl::ResponderPtr responder, S32 time_out)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1714,29 +1720,42 @@ void LLCurl::cleanupClass()
 			break ;
 		}
 	}
+	LL_CHECK_MEMORY
 	sCurlThread->shutdown() ;
+	LL_CHECK_MEMORY
 	delete sCurlThread ;
 	sCurlThread = NULL ;
+	LL_CHECK_MEMORY
 
 #if SAFE_SSL
 	CRYPTO_set_locking_callback(NULL);
 	for_each(sSSLMutex.begin(), sSSLMutex.end(), DeletePointer());
 #endif
+	
+	LL_CHECK_MEMORY
 
 	for (std::set<CURL*>::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter)
 	{
 		CURL* curl = *iter;
 		LLCurl::deleteEasyHandle(curl);
 	}
+	
+	LL_CHECK_MEMORY
 
 	Easy::sFreeHandles.clear();
 
+	LL_CHECK_MEMORY
+
 	delete Easy::sHandleMutexp ;
 	Easy::sHandleMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	delete sHandleMutexp ;
 	sHandleMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	// removed as per https://jira.secondlife.com/browse/SH-3115
 	//llassert(Easy::sActiveHandles.empty());
 }
@@ -1744,6 +1763,8 @@ void LLCurl::cleanupClass()
 //static 
 CURLM* LLCurl::newMultiHandle()
 {
+	llassert(sNotQuitting);
+
 	LLMutexLock lock(sHandleMutexp) ;
 
 	if(sTotalHandles + 1 > sMaxHandles)
@@ -1777,6 +1798,7 @@ CURLMcode  LLCurl::deleteMultiHandle(CURLM* handle)
 //static 
 CURL*  LLCurl::newEasyHandle()
 {
+	llassert(sNotQuitting);
 	LLMutexLock lock(sHandleMutexp) ;
 
 	if(sTotalHandles + 1 > sMaxHandles)
@@ -1801,7 +1823,9 @@ void  LLCurl::deleteEasyHandle(CURL* handle)
 	if(handle)
 	{
 		LLMutexLock lock(sHandleMutexp) ;
+		LL_CHECK_MEMORY
 		curl_easy_cleanup(handle) ;
+		LL_CHECK_MEMORY
 		sTotalHandles-- ;
 	}
 }
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 20ebd86c067138c2f4d56fcb76fda0f688bb29f4..7bcf61e233d6ff8967cc3b46c618cdf9d60a5cf6 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -44,6 +44,8 @@
 #include "llthread.h"
 #include "llqueuedthread.h"
 #include "llframetimer.h"
+#include "llpointer.h"
+
 
 class LLMutex;
 class LLCurlThread;
@@ -67,7 +69,7 @@ class LLCurl
 		F64 mSpeedDownload;
 	};
 	
-	class Responder
+	class Responder : public LLThreadSafeRefCount
 	{
 	//LOG_CLASS(Responder);
 	public:
@@ -126,13 +128,10 @@ class LLCurl
 				return false;
 			}
 
-	public: /* but not really -- don't touch this */
-		U32 mReferenceCount;
-
 	private:
 		std::string mURL;
 	};
-	typedef boost::intrusive_ptr<Responder>	ResponderPtr;
+	typedef LLPointer<Responder>	ResponderPtr;
 
 
 	/**
@@ -378,12 +377,6 @@ class LLCurlThread : public LLQueuedThread
 	void cleanupMulti(LLCurl::Multi* multi) ;
 } ;
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p);
-	void intrusive_ptr_release(LLCurl::Responder* p);
-};
-
 
 class LLCurlRequest
 {
diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp
index d84fe0a49fb1acee79ea78db06f697cc6c50449b..9b298d0c049ef5177018393c3d200d3ea2e51957 100644
--- a/indra/llmessage/tests/llcurl_stub.cpp
+++ b/indra/llmessage/tests/llcurl_stub.cpp
@@ -28,7 +28,6 @@
 #include "llcurl.h"
 
 LLCurl::Responder::Responder()
-	: mReferenceCount(0)
 {
 }
 
@@ -77,19 +76,3 @@ void LLCurl::Responder::result(LLSD const&)
 {
 }
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p)
-	{
-		++p->mReferenceCount;
-	}
-
-	void intrusive_ptr_release(LLCurl::Responder* p)
-	{
-		if(p && 0 == --p->mReferenceCount)
-		{
-			delete p;
-		}
-	}
-};
-
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
index 843c3bcc4bd6c09b7cdb04bd579853c2bea7d5be..a2be307cc8c304fbdbd9f7f1e32e5e824ea8cb38 100644
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ b/indra/llmessage/tests/llhttpclient_test.cpp
@@ -189,9 +189,9 @@ namespace tut
 			}
 		
 		public:
-			static boost::intrusive_ptr<Result> build(HTTPClientTestData& client)
+			static Result* build(HTTPClientTestData& client)
 			{
-				return boost::intrusive_ptr<Result>(new Result(client));
+				return new Result(client);
 			}
 			
 			~Result()
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c9458857d14e8cf46df6a0639cae1526f9978883..0a9d6229ef85d11e90f84f633f0a75276d921a06 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1891,8 +1891,17 @@ bool LLAppViewer::cleanup()
 	sTextureFetch->shutDownTextureCacheThread() ;
 	sTextureFetch->shutDownImageDecodeThread() ;
 
+	llinfos << "Shutting down message system" << llendflush;
+	end_messaging_system();
+
+	// *NOTE:Mani - The following call is not thread safe. 
+	LL_CHECK_MEMORY
+	LLCurl::cleanupClass();
+	LL_CHECK_MEMORY
+
 	LLFilePickerThread::cleanupClass();
 
+	//MUST happen AFTER LLCurl::cleanupClass
 	delete sTextureCache;
     sTextureCache = NULL;
 	delete sTextureFetch;
@@ -1961,12 +1970,6 @@ bool LLAppViewer::cleanup()
 
 	LLViewerAssetStatsFF::cleanup();
 	
-	llinfos << "Shutting down message system" << llendflush;
-	end_messaging_system();
-
-	// *NOTE:Mani - The following call is not thread safe. 
-	LLCurl::cleanupClass();
-
 	// If we're exiting to launch an URL, do that here so the screen
 	// is at the right resolution before we launch IE.
 	if (!gLaunchFileOnQuit.empty())
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 53c77fa22e52e09d13448a06c980c3903a78f488..e0ca1232b0da7b55c3abb7e49393d26e165b41e5 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -131,7 +131,9 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	// Note: This won't work when running from the debugger unless the _NO_DEBUG_HEAP environment variable is set to 1
 
 	// Enable to get mem debugging within visual studio.
-	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#if LL_DEBUG
+	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#else
 	_CrtSetDbgFlag(0); // default, just making explicit
 	
 	ULONG ulEnableLFH = 2;
@@ -145,6 +147,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 		else
 			heap_enable_lfh_error[i] = GetLastError();
 	}
+#endif
 #endif
 	
 	// *FIX: global
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 65bfc990d1eab087d5adb102024eccc089b52454..7b2c536f5add55b5a58027110a12cb2c477bd470 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -919,7 +919,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 	bool uploadConfirmationCallback(
 		const LLSD& notification,
 		const LLSD& response,
-		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+		LLPointer<LLNewAgentInventoryVariablePriceResponder> responder)
 	{
 		S32 option;
 		std::string confirmation_url;
@@ -949,7 +949,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 
 	void confirmUpload(
 		const std::string& confirmation_url,
-		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+		LLPointer<LLNewAgentInventoryVariablePriceResponder> responder)
 	{
 		if ( getFilename().empty() )
 		{
@@ -1124,7 +1124,7 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 		// and cause sadness.
 		mImpl->confirmUpload(
 			confirmation_url,
-			boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this));
+			LLPointer<LLNewAgentInventoryVariablePriceResponder>(this));
 	}
 	else
 	{
@@ -1157,7 +1157,7 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 				mImpl,
 				_1,
 				_2,
-				boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this)));
+				LLPointer<LLNewAgentInventoryVariablePriceResponder>(this)));
 	}
 }
 
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 4eda2b92b3224d52c891471dbe5ec981e1b004a9..954fd429a5618670143da931e4ca0c5bc29844fd 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -951,6 +951,12 @@ LLSpatialGroup* LLDrawable::getSpatialGroup() const
 
 void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 {
+	//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this
+	llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this));
+
+	//precondition: groupp MUST be null or groupp MUST contain this
+	llassert(!groupp || groupp->hasElement(this));
+
 /*if (mSpatialGroupp && (groupp != mSpatialGroupp))
 	{
 		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
@@ -970,9 +976,12 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 		}
 	}
 
-	mSpatialGroupp = groupp;
+	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
+	//postcondition: if next group is NOT NULL, binIndex must not be -1
+	llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 :
+							getBinIndex() != -1);
 
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
+	mSpatialGroupp = groupp;
 }
 
 LLSpatialPartition* LLDrawable::getSpatialPartition()
@@ -1400,7 +1409,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 		markDead();
 		return;
 	}
-	
+
 	if (gShiftFrame)
 	{
 		return;
@@ -1483,13 +1492,11 @@ void LLSpatialBridge::cleanupReferences()
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
-		LLSpatialGroup* group = mDrawable->getSpatialGroup();
-		if (group)
-		{
-			group->mOctreeNode->remove(mDrawable);
-			mDrawable->setSpatialGroup(NULL);
-		}
+		/*
 		
+		DON'T DO THIS -- this should happen through octree destruction
+
+		mDrawable->setSpatialGroup(NULL);
 		if (mDrawable->getVObj())
 		{
 			LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren();
@@ -1500,15 +1507,10 @@ void LLSpatialBridge::cleanupReferences()
 				LLDrawable* drawable = child->mDrawable;					
 				if (drawable)
 				{
-					LLSpatialGroup* group = drawable->getSpatialGroup();
-					if (group)
-					{
-						group->mOctreeNode->remove(drawable);
-						drawable->setSpatialGroup(NULL);
-					}
+					drawable->setSpatialGroup(NULL);
 				}
 			}
-		}
+		}*/
 
 		LLDrawable* drawablep = mDrawable;
 		mDrawable = NULL;
diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp
index 4f4d9a40b4a6d5c40f247e9266b4771ab714e9a1..2c786b7f8be8714ee90e27a76e623eddb84d71a6 100644
--- a/indra/newview/lleventpoll.cpp
+++ b/indra/newview/lleventpoll.cpp
@@ -86,7 +86,7 @@ namespace
 
 	class LLEventPollEventTimer : public LLEventTimer
 	{
-		typedef boost::intrusive_ptr<LLEventPollResponder> EventPollResponderPtr;
+		typedef LLPointer<LLEventPollResponder> EventPollResponderPtr;
 
 	public:
 		LLEventPollEventTimer(F32 period, EventPollResponderPtr responder)
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index c5df7e16e97c639a0a9e6bdc06f97950446d055e..a242b224cd7fab1b538d4edad4bd287a8c1afc5b 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -71,9 +71,9 @@ class LLIamHere : public LLHTTPClient::Responder
 
 	public:
 
-		static boost::intrusive_ptr< LLIamHere > build( LLFloaterTOS* parent )
+		static LLIamHere* build( LLFloaterTOS* parent )
 		{
-			return boost::intrusive_ptr< LLIamHere >( new LLIamHere( parent ) );
+			return new LLIamHere( parent );
 		};
 		
 		virtual void  setParent( LLFloaterTOS* parentIn )
@@ -102,7 +102,7 @@ class LLIamHere : public LLHTTPClient::Responder
 
 // this is global and not a class member to keep crud out of the header file
 namespace {
-	boost::intrusive_ptr< LLIamHere > gResponsePtr = 0;
+	LLPointer< LLIamHere > gResponsePtr = 0;
 };
 
 BOOL LLFloaterTOS::postBuild()
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 06c87e57fc77a6baa32ec02b3f983f6b5a0fd3e5..b815439834c98925f5af623c08b1f34ed5c01821 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1859,6 +1859,8 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 		drawablep->setSpatialGroup(NULL);
 	}
 
+	drawablep->setSpatialGroup(NULL);
+
 	assert_octree_valid(mOctree);
 	
 	return TRUE;
@@ -4194,7 +4196,7 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 						{
 							if (index < 255)
 							{
-								if (facep->mDrawInfo->mTextureList.size()<= index)
+								if (facep->mDrawInfo->mTextureList.size() <= index)
 								{
 									llerrs << "Face texture index out of bounds." << llendl;
 								}
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index f050df2b3945709ce0c400038ce3c47a32b79713..e63037b4a8c0c18325ce66bf5293d6c9d224d362 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -350,6 +350,8 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	element_list& getData() { return mOctreeNode->getData(); }
 	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
 	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
+	bool hasElement(LLDrawable* drawablep) { return std::find(mOctreeNode->getDataBegin(), mOctreeNode->getDataEnd(), drawablep) != mOctreeNode->getDataEnd(); }
+
 	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
 	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 7adf5212c280826476972313a21859dd1836f5f6..adffb2c7064577bc91a217d9ddc816e0edf7dc03 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2977,7 +2977,9 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
         
         ~lcl_responder()
             {
+				LL_CHECK_MEMORY
                 mFetcher->decrCurlPOSTCount();
+				LL_CHECK_MEMORY
             }
 
 		// virtual
diff --git a/indra/newview/lltranslate.h b/indra/newview/lltranslate.h
index c58e1adb8ca031a9061c1aae15502fd455e9dc88..db5ad9479c13c5bb2f9b42a45ebb8e72b696babb 100755
--- a/indra/newview/lltranslate.h
+++ b/indra/newview/lltranslate.h
@@ -263,8 +263,8 @@ public :
 		EService mService;
 	};
 
-	typedef boost::intrusive_ptr<TranslationReceiver> TranslationReceiverPtr;
-	typedef boost::intrusive_ptr<KeyVerificationReceiver> KeyVerificationReceiverPtr;
+	typedef LLPointer<TranslationReceiver> TranslationReceiverPtr;
+	typedef LLPointer<KeyVerificationReceiver> KeyVerificationReceiverPtr;
 
 	/**
 	 * Translate given text.
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 903f4437a7ea11bcf1d53529fcf8ef39f78beb34..b048332e59e82f486c247d20556c4855b65fc6c1 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3340,9 +3340,9 @@ public :
 	{
 	}
 
-	static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
+	static ChatTranslationReceiver* build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
 	{
-		return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args));
+		return new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args);
 	}
 
 protected:
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index effa368b7ac251e6603e7ba4edd945b1f1f5c561..5a5df7caf648b473486f669c283bcfae735ade2e 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -255,10 +255,9 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 		}
 	}
 
-    static boost::intrusive_ptr<BaseCapabilitiesComplete> build( U64 region_handle, S32 id )
+    static BaseCapabilitiesComplete* build( U64 region_handle, S32 id )
     {
-		return boost::intrusive_ptr<BaseCapabilitiesComplete>( 
-				new BaseCapabilitiesComplete(region_handle, id) );
+		return new BaseCapabilitiesComplete(region_handle, id);
     }
 
 private:
diff --git a/indra/newview/tests/lltranslate_test.cpp b/indra/newview/tests/lltranslate_test.cpp
index 10e37fae97f8096e59166f5911dc6615bac25fc1..fd9527d631a921ce957e8b41e1b56a1c98ec4123 100644
--- a/indra/newview/tests/lltranslate_test.cpp
+++ b/indra/newview/tests/lltranslate_test.cpp
@@ -299,11 +299,6 @@ LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLCo
 std::string LLControlGroup::getString(const std::string& name) { return "dummy"; }
 LLControlGroup::~LLControlGroup() {}
 
-namespace boost {
-	void intrusive_ptr_add_ref(LLCurl::Responder*) {}
-	void intrusive_ptr_release(LLCurl::Responder*) {}
-}
-
 LLCurl::Responder::Responder() {}
 void LLCurl::Responder::completedHeader(U32, std::string const&, LLSD const&) {}
 void LLCurl::Responder::completedRaw(U32, const std::string&, const LLChannelDescriptors&, const LLIOPipe::buffer_ptr_t& buffer) {}
@@ -314,7 +309,7 @@ void LLCurl::Responder::result(LLSD const&) {}
 LLCurl::Responder::~Responder() {}
 
 void LLHTTPClient::get(const std::string&, const LLSD&, ResponderPtr, const LLSD&, const F32) {}
-void LLHTTPClient::get(const std::string&, boost::intrusive_ptr<LLCurl::Responder>, const LLSD&, const F32) {}
+void LLHTTPClient::get(const std::string&, LLPointer<LLCurl::Responder>, const LLSD&, const F32) {}
 
 LLBufferStream::LLBufferStream(const LLChannelDescriptors& channels, LLBufferArray* buffer)
 :	std::iostream(&mStreamBuf), mStreamBuf(channels, buffer) {}
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 1bc8306826e55046ce1f05e40c26194a483090c4..99dcc90f8f2a59423fa38e9ee3735cc691ab42aa 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -537,6 +537,7 @@ def wpath(path):
                 result += 'File ' + pkg_file + '\n'
             else:
                 result += 'Delete ' + wpath(os.path.join('$INSTDIR', rel_file)) + '\n'
+
         # at the end of a delete, just rmdir all the directories
         if not install:
             deleted_file_dirs = [os.path.dirname(pair[1].replace(self.get_dst_prefix()+os.path.sep,'')) for pair in self.file_list]
@@ -1105,9 +1106,7 @@ def construct(self):
             # version number.
             self.path("libfontconfig.so.*.*")
             try:
-                self.path("libtcmalloc.so", "libtcmalloc.so") #formerly called google perf tools
-                self.path("libtcmalloc.so.0", "libtcmalloc.so.0") #formerly called google perf tools
-                self.path("libtcmalloc.so.0.1.0", "libtcmalloc.so.0.1.0") #formerly called google perf tools
+                self.path("libtcmalloc.so*") #formerly called google perf tools
                 pass
             except:
                 print "tcmalloc files not found, skipping"
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 4da774a5f6bf7b87988be7c3d899f1247e029c53..5edbbf9914cbfb7ae52f17f24cade54377e8ba91 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -51,37 +51,6 @@ class LLUpdateChecker::CheckError:
 };
 
 
-class LLUpdateChecker::Implementation:
-	public LLHTTPClient::Responder
-{
-public:
-	Implementation(Client & client);
-	~Implementation();
-	void checkVersion(std::string const & protocolVersion, std::string const & hostUrl, 
-			   std::string const & servicePath, std::string channel, std::string version);
-	
-	// Responder:
-	virtual void completed(U32 status,
-						   const std::string & reason,
-						   const LLSD& content);
-	virtual void error(U32 status, const std::string & reason);
-	
-private:	
-	static const char * sProtocolVersion;
-	
-	Client & mClient;
-	LLHTTPClient mHttpClient;
-	bool mInProgress;
-	std::string mVersion;
-	
-	std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl, 
-						 std::string const & servicePath, std::string channel, std::string version);
-
-	LOG_CLASS(LLUpdateChecker::Implementation);
-};
-
-
-
 // LLUpdateChecker
 //-----------------------------------------------------------------------------
 
@@ -134,13 +103,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & protocolV
 	std::string checkUrl = buildUrl(protocolVersion, hostUrl, servicePath, channel, version);
 	LL_INFOS("UpdateCheck") << "checking for updates at " << checkUrl << llendl;
 	
-	// The HTTP client will wrap a raw pointer in a boost::intrusive_ptr causing the
-	// passed object to be silently and automatically deleted.  We pass a self-
-	// referential intrusive pointer to which we add a reference to keep the
-	// client from deleting the update checker implementation instance.
-	LLHTTPClient::ResponderPtr temporaryPtr(this);
-	boost::intrusive_ptr_add_ref(temporaryPtr.get());
-	mHttpClient.get(checkUrl, temporaryPtr);
+	mHttpClient.get(checkUrl, this);
 }
 
 void LLUpdateChecker::Implementation::completed(U32 status,
diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h
index d882169068f726061c8ec671cfb16c87502dc5e7..23f62a7c5eee98b265e99935cad6edc2f8425f98 100644
--- a/indra/viewer_components/updater/llupdatechecker.h
+++ b/indra/viewer_components/updater/llupdatechecker.h
@@ -29,6 +29,7 @@
 
 #include <boost/shared_ptr.hpp>
 
+#include "llhttpclient.h"
 
 //
 // Implements asynchronous checking for updates.
@@ -36,7 +37,36 @@
 class LLUpdateChecker {
 public:
 	class Client;
-	class Implementation;
+	class Implementation:
+
+	public LLHTTPClient::Responder
+	{
+	public:
+		Implementation(Client & client);
+		~Implementation();
+		void checkVersion(std::string const & protocolVersion, std::string const & hostUrl, 
+				   std::string const & servicePath, std::string channel, std::string version);
+	
+		// Responder:
+		virtual void completed(U32 status,
+							   const std::string & reason,
+							   const LLSD& content);
+		virtual void error(U32 status, const std::string & reason);
+	
+	private:	
+		static const char * sProtocolVersion;
+	
+		Client & mClient;
+		LLHTTPClient mHttpClient;
+		bool mInProgress;
+		std::string mVersion;
+	
+		std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl, 
+							 std::string const & servicePath, std::string channel, std::string version);
+
+		LOG_CLASS(LLUpdateChecker::Implementation);
+	};
+
 	
 	// An exception that may be raised on check errors.
 	class CheckError;
@@ -48,7 +78,7 @@ class LLUpdateChecker {
 			   std::string const & servicePath, std::string channel, std::string version);
 	
 private:
-	boost::shared_ptr<Implementation> mImplementation;
+	LLPointer<Implementation> mImplementation;
 };