I am trying to load about 50 files in to eXist. Several of the files are large (169 MB (177,789,575 bytes)). I've tried to increase the max memory but it continues to fail. I am using eXist version 1.1.1 embedded in a simple app. My initial goal was to verify I could load the files in to eXist.

Here is the method that loads the files:
        public static void loadFile(File file, Collection collection) throws XMLDBException, SAXException, IOException {

                // File containing the XML to be inserted
                String fileName = file.getAbsolutePath();

                String id = file.getName().replaceAll("\\.xml", "");
                XMLResource resource =
                   (XMLResource) collection.createResource(id, XMLResource.RESOURCE_TYPE);

                ContentHandler handler = resource.setContentAsSAX();
                XMLReader reader = XMLReaderFactory.createXMLReader();
                reader.parse(new InputSource(fileName));


Exception Message:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Is there a limit on file size or some option that consumes less memory? Maybe a custom ContentHandler?

Thanks in advance!