3f517fdfbeda1a52d3af4f11e232008e9b3c06fc
galt
  Thu Mar 20 15:13:56 2014 -0700
Since the max arena setting seems to have a bug, we are using a different approach that is probably better anway. -- using RSS instead of DATA for rlimit.  This will work with the new glibc malloc for multiple threads.
diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 1a66fe1..b7b49cf 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -1,25 +1,22 @@
 /* hgTracks - the original, and still the largest module for the UCSC Human Genome
  * Browser main cgi script.  Currently contains most of the track framework, though
  * there's quite a bit of other framework type code in simpleTracks.c.  The main
  * routine got moved to create a new entry point to the bulk of the code for the
  * hgRenderTracks web service.  See mainMain.c for the main used by the hgTracks CGI. */
 
 #include <pthread.h>
-#ifndef __APPLE__
-#include <malloc.h>
-#endif
 #include "common.h"
 #include "hCommon.h"
 #include "linefile.h"
 #include "portable.h"
 #include "memalloc.h"
 #include "localmem.h"
 #include "obscure.h"
 #include "dystring.h"
 #include "hash.h"
 #include "jksql.h"
 #include "gfxPoly.h"
 #include "memgfx.h"
 #include "hvGfx.h"
 #include "psGfx.h"
 #include "cheapcgi.h"
@@ -4417,66 +4414,49 @@
         limitSuperTrackVis(track);
 
     /* remove cart priority variables if they are set
        to the default values in the trackDb */
     if (!hTrackOnChrom(track->tdb, chromName))
         {
         track->limitedVis = tvHide;
         track->limitedVisSet = TRUE;
 	}
     }
 
 /* pre-load remote tracks in parallel */
 int ptMax = atoi(cfgOptionDefault("parallelFetch.threads", "20"));  // default number of threads for parallel fetch.
 int pfdListCount = 0;
 pthread_t *threads = NULL;
-pthread_attr_t attr;
-int stackSize = 2*1024*1024;  // 2 MB per thread? 10MB is default on 64-bit
 if (ptMax > 0)     // parallelFetch.threads=0 to disable parallel fetch
     {
     findLeavesForParallelLoad(trackList, &pfdList);
     pfdListCount = slCount(pfdList);
     /* launch parallel threads */
     ptMax = min(ptMax, pfdListCount);
     if (ptMax > 0)
 	{
 	AllocArray(threads, ptMax);
-
-	#if defined(M_ARENA_MAX) 
-	    mallopt(M_ARENA_MAX, 8);   // Otherwise new glibc allocates 64MB arena per thread
-	#endif /* glibc malloc tuning */ 
-
-	/* Initialize thread creation attributes */
-	int rc = pthread_attr_init(&attr);
-	if (rc) errAbort("Unexpected error %d from pthread_attr_init(): %s",rc,strerror(rc));
-	/* Set thread stack size */
-	rc = pthread_attr_setstacksize(&attr, stackSize);
-	if (rc) errAbort("Unexpected error %d from pthread_attr_setstacksize(): %s",rc,strerror(rc));
 	/* Create threads */
 	int pt;
 	for (pt = 0; pt < ptMax; ++pt)
 	    {
-	    rc = pthread_create(&threads[pt], &attr, remoteParallelLoad, &threads[pt]);
+	    int rc = pthread_create(&threads[pt], NULL, remoteParallelLoad, &threads[pt]);
 	    if (rc)
 		{
 		errAbort("Unexpected error %d from pthread_create(): %s",rc,strerror(rc));
 		}
 	    }
-	/* Thread attr no longer needed */
-	rc = pthread_attr_destroy(&attr);
-	if (rc) errAbort("Unexpected error %d from pthread_attr_destroy(): %s",rc,strerror(rc));
-
 	}
     }
 
 /* load regular tracks */
 for (track = trackList; track != NULL; track = track->next)
     {
     if (track->visibility != tvHide)
 	{
 	if (!track->parallelLoading)
 	    {
 	    if (measureTiming)
 		lastTime = clock1000();
 
 	    checkMaxWindowToDraw(track);
 	    track->loadItems(track);