Alex F's objection emphasizes that your program may be suffering from a memory or other resource leak. Did you try to observe memory consumption of the program using Task Manager or Sysinternals' Process Explorer? If you don't observe a steady increase in memory consumption, you should have a look at the GDI object count and handle count.
Also, the methods from the System::Drawing namespace are more or less known for throwing an OutOfMemoryException in case the underlying GDI+ function encounters any problem in handling the bitmap format. (This has for instance been discussed in http://www.codeguru.com/forum/showthread.php?t=513030.) Perhaps they may even do that if it's not documented on MSDN (which would be the case for Graphics::DrawImage()). While I'm not quite sure now whether that's true for that sort of GDI+ problems as well, in general the information carried by the .NET exception objects often is quite helpful, so I'd say it's definitely worth a try to have a closer look at the exception object you catch. In case it's a GDI+ problem, the exception being thrown is likely to be correlated to the use of certain (types of) bitmap objects and/or rotation angles.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
It is not very easy to reproduce the exception (since as I wrote it appears in unexpected moments). However I am now disposing the Graphics, and also I have rewrite a bit my source code, because i was kind of exploiting this method .
Now I don't get this out of memory error anymore. When I will have some spare time I will look into what You have written Eri.
Thanks for your help and time guys !
Best regards,
Smallbit.
Bookmarks