Exception: Insufficient memory to continue the execution of the program
I am referencing an ActiveX dll in my .NET application and getting an "Insufficient memory to continue the execution of the program" exception th开发者_运维技巧rown on a user that loads large amounts of data from this ActiveX object.
What is the recommended method to solve this problem?
The company that develops this dll isn't very thrilled to fix the bug, so I'm trying to handle this myself.
Thanks
Assuming that it is the ActiveX control that is consuming the memory and not your code, I'm not sure that there is anything that you can do, other than perhaps attempt to use the ActiveX control in a slightly different way that either uses less memory or protects against this exception for example:
- Prevent someone loading too many data sets at once.
- Somehow split a large data set into several smaller data sets.
- Use a 64bit process.
- Try splitting the memory pressure over multiple processes somehow.
Of course this will all depend on the specifics of the ActiveX control, and so its difficult to say whether or not this is feasible without knowing more about the control.
According to this answer there is a machine.config setting which allows you to increase the per-process memory limit which may help a little - you should also read the second answer on this question which goes into more detail about why this exception happens.
精彩评论