I think, I'm encountering a similar problem with Xerces 2.7.0. Xerces crashes when maxOccurs is too large.
Xerces always allocates memory for elements according to the number specified in maxOccurs, regardless of the real number of elements in xml instance. If the real numer of elements is small, most allocated elements are not needed.
<xs:element name="serialNumber" maxOccurs="10000"/>
In this case 10000 elements are created, but only 1 is really needed. I found the following code fragment in ComplexTypeInfo::expandContentModel:
for (int j=1; j < maxOccurs-minOccurs; j++)
retNode = new (fMemoryManager) ContentSpecNode
In my case I have a xml schema which uses maxOccurs="9999999". So each time this element is found in a xml instance 9999999 elements are created although normally just a few are really needed. So I'd also prefer a counting version which creates only the really needed elements.