P-invoke call fails if too much memory is assigned beforehand

Posted by RandomEngy on Stack Overflow See other posts from Stack Overflow or by RandomEngy
Published on 2010-05-16T17:26:59Z Indexed on 2010/05/16 17:30 UTC
Read the original article Hit count: 206

Filed under:
|
|
|

I've got a p-invoke call to an unmanaged DLL that was failing in my WPF app but not in a simple, starter WPF app. I tried to figure out what the problem was but eventually came to the conclusion that if I assign too much memory before making the call, the call fails. I had two separate blocks of code, both of which would succeed on their own, but that would cause failure if both were run. (They had nothing to do with what the p-invoke call is trying to do).

What kind of issues in the unmanaged library would cause such an issue? I thought that the managed and unmanaged heaps were supposed to be automatically separated.

The crash as far as I can tell is happening in a dynamically loaded secondary DLL from the one p-invoked into. Could that have something to do with it?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about pinvoke