Link to home
Start Free TrialLog in
Avatar of Naveen Kumar
Naveen Kumar

asked on

Out of memory exception while graphics.drawimage

i have draw one bitmap file using graphic. some times application has through Out of memory or invalid parameter  exception. am using Dispose and flush everyone to dispose a object some time its drawn 10000 images sometimes its drawn 20 images only can you give idea. actually the drawing process happened inside the loop but that functionality calling through thread only.
Avatar of Ark
Ark
Flag of Russian Federation image

All drawings occured when control is invalidated, i.e overlapped with another window, moved etc. each time control receives WM_PAINT message. When this occures during your loop it starts again, holding previous loop in memory. You can use boolean variable to restrict repetition drawing:
Private bDrawing as Boolean
'Your drawing sub
If bDrawing Then Return
bDrawing = True
Do
'Drawing inside loop
Loop
bDrawing = false

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.