AccessViolationException when invoking WorkflowInvoker.Invoke RRS feed

  • Question

  • I'm trying to run a parallel foreach loop with 32 threads.

    This foreach loop is calling a:

    WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary)

    The parallel foreach loop consists of a list of around 65000 items.

    At some point, at around 6000 - 6700 items the invocation of WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary) throws an AccessViolationException with the message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    I have tried different things, like creating an instance of the WorkflowInvoker and passing an instance of MyWorkflow directly to the newly created WorkflowInvoker and then calling the Invoke method on the class. Also just calling the WorkflowInvoker.Invoke as a static method, but it doesn't make a difference. The application crashes at the same point every time. Because of the threads it's hard to debug and pinpoint exactly what is causing the trouble.

    Of course the problems doesn't occur if I'm doing the calls in a normal foreach loop.

    At first we thought the virtual machine was running low on memory, because the application started eating all available memory until it reached a limit of 85% of the total memory (4GB) and then it seemed to crash. So we changed the memory size to 1GB, to see if we could induce the exception earlier in the loop, but instead Windows started garbagecollecting, so in the end the exception still occured at the same point around 6000 - 6700 items.

    Any suggestions as to what should be my next move, is much appreciated ;-)

    This question has also been posted on StackOverflow, but with no luck atm.

    On a side-note, we have also tried to run the Parallel.ForEach with 64, 16 and 2 threads. All crashes at around 6000 - 6700 items.

    Also we have tried with the same data in each item in the list, so to be sure, that it was not a specific item in the list that crashes the application. It didn't make a difference, however.

    Link to the SO thread: http://stackoverflow.com/questions/12283360/accessviolationexception-when-calling-workflowinvoker-invoke

    • Edited by Pinnodyr Thursday, September 6, 2012 2:39 PM Formatting of the text was horrible. ;-)
    Thursday, September 6, 2012 2:36 PM