Select to view content in your preferred language

Throwing AccessViolationException when querying data of featureClass

1347
2
08-29-2014 03:33 AM
CarstenSchumann
Frequent Contributor

Hey there,

when I query a featureClass with featureClass.Search(filter, true) I get the exception mentioned above. Unfortunately I cannot reproduce this error in any way, it happens only on production-machine of a customer. But hence the data being queried is quite huge (some millions of points) searching for the one feature that fails nearly impossible or at least quite annoying. My customer also guaranteed that there are no writing processes on the featureClass (SDE-version), so I wonder where this exception may come from. To save memory I release every row after having handled it (calling Marshal.ReleaseComObject within a loop as long as references exist):

List<string> UUIDs = new List<string>();

IQueryFilter filter = new QueryFilter { SubFields = "UUID"};  // this should save us so much time

cursor = ((ITable)dataset).Search(filter, true); // we take a recycling-cursor because we handle only immutable strings (UUIDs)

while ((row = cursor.NextRow()) != null)

{

     UUIDs.Add((string)row.get_Value(1));

     ReleaseComObject(row);                      // release the underlying COM-object as often as references exist

}

After many thousands of features handled we get the exception. Unfortunately I could not even print any ID of the faulty feature to handle it manually because I cannot access it. I do not have any clue how I may get around the issue or at least how to avoid it.

Kind regards

Tags (2)
0 Kudos
2 Replies
ErinBrimhall
Deactivated User

Have you tried the call to Search with recycling = false?

The name of that parameter and its related documentation make it sound very appealing, but I have ran into more problems than not when using recycling = true.

As you mentioned, you're already releasing the row object after each iteration, so your memory footprint should remain fairly stable as the while-loop executes.

0 Kudos
CarstenSchumann
Frequent Contributor

I will try this out, but can take some days to test it within production-environment. I´ll let you know as far as I have further information...

EDIT:

After having changed it to non-recycling cursor the error still occurs within my  customers environment, although now enclosed within a OutOfMemory-Exception from log4net:

<log4net.Error>Exception rendering object type [System.AccessViolationException]<stackTrace>System.OutOfMemoryException: Eine Ausnahme vom Typ "System.OutOfMemoryException" wurde ausgelöst.

bei log4net.ObjectRenderer.RendererMap.Get(Type type)

bei log4net.ObjectRenderer.RendererMap.FindAndRender(Object obj, TextWriter writer)</stackTrace></log4net.Error>

However I suppose this is the same error as mentioned previously, handling the AVE (hopefully) eliminates this strange surrounding one as well (although its a great miracle that machine runs out of memory when logging an exception).

BTW: I copied the data from customer to development-machine. But the error does not occur here, so its obviously no data-error

0 Kudos