       break
 
      n -= size
-     if size isnt MAX_SIZE
+     if size isnt MAX_SIZE and
+     size * 2 * struct.bytes <= MAX_BYTES
       size = size << 1
    else
     capacity = INT_SIZE
     if min_capacity?
-     while capacity isnt MAX_SIZE and capacity < min_capacity
+     while capacity isnt MAX_SIZE and capacity < min_capacity and
+     capacity * 2 * struct.bytes <= MAX_BYTES
       capacity = capacity << 1
     size = capacity
     lastArr = TDS.Array struct, capacity

   constructor: ->
    size = INT_SIZE
    n = length * STRING_AVG_LEN
    while size isnt MAX_SIZE and size < n
     size = size << 1
    buffers = [new ArrayBuffer size << 1]
    views = [new Int16Array buffers[0]]


   addArray: ->
    size = lastViewLen
    while size isnt MAX_SIZE and
    size * 2 * 2 <= MAX_BYTES
     size = size << 1
    b = new ArrayBuffer size << 1
    buffers.push b
