I am using the ArcObjects API for Java to load a very large dataset in a File Geodatabase in one feature class.

The whole dataset I have to load is composed of 200 datasets of 30k polygons, and I load the datasets one after the other. I read data from XML files (I am sure there is no memory leak in this step).

The loading process is in a BaseGeoprocessingTool.

Here is my code to write the data of one dataset in the feature class:

    IFeatureClass featureClass = ...
    IFeatureCursor insertCursor = featureClass.IFeatureClass_insert(false); // true uses too much memory
    IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer();
    IGeometry geometry = null;
    List<Integer> fieldIdsToClear = new ArrayList<Integer>();

    for(FeatureBean featureBean : features) {
        if(log.canContinue()) {
            geometry = featureBean.geometry.getGeometry();
            if(toBeProjected) geometry.project(toSpatialReference);

            // reset the fields in the featureBuffer
            for(Integer fieldId : fieldIdsToClear) {
                featureBuffer.setValue(fieldId, Variant.VT_NULL);

            featureBuffer.setValue(idFieldId, (int)featureBean.id);

            for(Entry<String, String> tag : featureBean.tagMap.entrySet()) {
                int fieldId = fieldIdMap.get(tag.getKey());
                featureBuffer.setValue(fieldId, tag.getValue());




After reading these advices, I use an insert cursor instead of IFeature.store() so that process is ~5x faster. So, I do not recreate the FeatureBuffer each time I insert a new feature. Instead of, I reuse it and clear the necessary fields.

This process works well and is very fast. Nevertheless, there is a memory leak. Watching ArcMap.exe process memory, we can see that it uses about 100 Mb to load each dataset, then the memory is not released, even if objects are released in my code. When memory is about 1300 Mb (only after loaded the 5th dataset), the process crashes on the exception AutomationException: One or more arguments are invalid

I have tried different Java max heap sizes with JavaConfigTool.exe between 512 and 1900 Mb, but it doesn't change anything.

What solution could I try to be sure that ArcGIS really release useless objects? As I have a lot of datasets to load, I really need to release to get back the 100 Mb each time a dataset has been loaded.

Any help is welcome to optimize my process.

EDIT: I use ArcGIS 10.2 with Background Geoprocessing (64bits) and have 8 Go of RAM.

  • 3
    Perhaps try flushing the buffer every so often inside the loop. As a guide, I usually do this every 2000 rows. – nef001 Apr 16 '15 at 12:40
  • Thanks for this good idea, I just tried to flush every 2000 features but the ArcMap.exe process keeps not releasing its memory between each dataset, then crashes. – superrache Apr 16 '15 at 13:01
  • 1
    I second what @nef001 suggested, it may help to flush the features at every n number of rows. At this years dev summit, an esri geodatabase developer suggested to flush at every 1000 features. Maybe try that instead of 2000? I would think 2000 would be a safe number though. – crmackey Apr 16 '15 at 13:04
  • Unfortunately, I got the same flushing every 1000 features and so on every 1 feature. I feel that the memory consumption is optimal when loading a dataset, but need to be freed between each dataset loading. – superrache Apr 16 '15 at 13:26
  • Any other idea? I'm still blocked on this problem. This is really troublesome because I have to restart ArcMap to free the memory. Even when the geoprocess is finished, memory is still full. – superrache May 4 '15 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.