src/hg/lib/wigDataStream.c 1.86
1.86 2009/12/21 18:37:10 hiram
Raise memory limit for data fetch operations
Index: src/hg/lib/wigDataStream.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/wigDataStream.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -b -B -U 4 -r1.85 -r1.86
--- src/hg/lib/wigDataStream.c 12 Mar 2009 20:56:40 -0000 1.85
+++ src/hg/lib/wigDataStream.c 21 Dec 2009 18:37:10 -0000 1.86
@@ -8,8 +8,12 @@
#include "hgColors.h"
#include "obscure.h"
#include "customTrack.h"
+/* size of memory to work with during wiggle data fetch operations,
+ * ~4 Gb is good enough for about 750,000,000 bases */
+#define HUGE_LIMIT 4280000000
+
static char const rcsid[] = "$Id$";
/* Routines that are not strictly part of the wigDataStream object,
but they are used to do things with the object.
@@ -927,17 +931,16 @@
hugeSize = (unsigned long long)sizeof(float) * (unsigned long long)winSize;
if (sizeof(size_t) == 4)
{
- if (hugeSize > 2100000000)
+ if (hugeSize > HUGE_LIMIT)
{
warn("ERROR: Can not perform requested data operation.<BR>");
errAbort("Not enough memory (requested: %llu bytes)", hugeSize);
}
}
size = sizeof(float) * winSize;
- /* good enough for 500,000,000 bases */
- setMaxAlloc((size_t)2100000000); /*2^31 = 2,147,483,648 */
+ setMaxAlloc((size_t)HUGE_LIMIT);
if (verboseLevel() >= VERBOSE_CHR_LEVEL)
startTime = clock1000();
wa->data = (float *)needLargeMem(size);
dataArrayPtr = wa->data;
@@ -1418,10 +1421,9 @@
if (count < 1)
return floatArray;
-/* good enough for 500,000,000 bases */
-setMaxAlloc((size_t)2100000000); /*2^31 = 2,147,483,648 */
+setMaxAlloc((size_t)HUGE_LIMIT);
AllocArray(floatArray, count);
fptr = floatArray;
@@ -1648,10 +1650,9 @@
/* must use the larger of the two sizes */
bedArraySize = max(winExtent,bedExtent);
bedArraySize *= sizeof(char); /* in bytes */
- /* good enough for 2,000,000,000 bases (bedArray elem 1 byte) */
- setMaxAlloc((size_t)2100000000); /*2^31 = 2,147,483,648 */
+ setMaxAlloc((size_t)HUGE_LIMIT);
if (verboseLevel() >= VERBOSE_CHR_LEVEL)
startTime = clock1000();
bedArray = (char *)needLargeMem(bedArraySize);
@@ -1767,12 +1768,12 @@
wigAscii->chrom = cloneString(wds->chrName);
wigAscii->span = 1; /* span information has been lost */
wigAscii->count = 0; /* will count up as values added */
wigAscii->dataRange = 0.0; /* to be determined */
- setMaxAlloc((size_t)( 2100000000 *
+ setMaxAlloc((size_t)( HUGE_LIMIT *
(((sizeof(size_t)/4)*(sizeof(size_t)/4)*(sizeof(size_t)/4)))));
- /* produces: size_t is 4 == 2100000000 ~= 2^31 = 2Gb
- * size_t is 8 = 16800000000 ~= 2^34 = 16 Gb
+ /* produces: size_t is 4 ~= 4 Gb
+ * size_t is 8 ~= 32 Gb
*/
verbose(VERBOSE_CHR_LEVEL,
"#\tworst case ascii array needLargeMem (%llu * %llu = %llu)\n",
(unsigned long long)sizeof(struct asciiDatum),
@@ -1909,12 +1910,12 @@
newSize = sizeof(struct asciiDatum) * wigAscii->count;
if (newSize > 0)
{
- setMaxAlloc((size_t)( 2100000000 *
+ setMaxAlloc((size_t)( HUGE_LIMIT *
(((sizeof(size_t)/4)*(sizeof(size_t)/4)*(sizeof(size_t)/4)))));
- /* produces: size_t is 4 == 2100000000 ~= 2^31 = 2Gb
- * size_t is 8 = 16800000000 ~= 2^34 = 16 Gb
+ /* produces: size_t is 4 ~= 4 Gb
+ * size_t is 8 ~= 32 Gb
*/
verbose(VERBOSE_CHR_LEVEL,
"#\tmoving to smaller ascii array needLargeMem( %llu * %llu = %llu)\n",
(unsigned long long)sizeof(struct asciiDatum),