0

I have a VB.Net code in Visual Studio which captures a bunch of windows clicks different buttons on these windows. But every 15 minutes, the app crashes and this error pops up.

Does anyone know what it means and the best or easiest way to handle it?

Thanks.

  • this exception means that you're out of memory, to handle it - check all places where memory allocation occurs, add try/catch to this blocks, find block which tries to allocate unreal amount of memory – Iłya Bursov Oct 31 '13 at 18:23
  • could you show what to edit in my code to do this: hwnd = FindWindow(vbNullString, "Description") If hwnd <> Nothing Then btn = FindWindowEx(hwnd, 0, "Button", "Cancel") If btn <> Nothing Then Do Until btn = Nothing Threading.Thread.Sleep(200) SendMessage(btn, BM_CLICK, 0, 0) Threading.Thread.Sleep(200) btn = FindWindowEx(hwnd, 0, "Button", "Cancel") Loop Threading.Thread.Sleep(3000) End If End If – Jayesh Surendran Menon Oct 31 '13 at 18:34
  • Can i simply just do On Error Resume Next – Jayesh Surendran Menon Oct 31 '13 at 18:54

2 Answers2

0

Disposing forms after you are done with them is a great way to avoid that exception. Also look here : Memory Management

Community
  • 1
  • 1
Iman B. Rad
  • 57
  • 1
  • 7
0

I had the same error when I used a While loop to loop through a string array of names and adding each name to a dropdownlist where the text would be the name from the string.

The problem was I did not add 1 to the index. Adding 1 to the index solved the problem for me. Hope it helps

Garret
  • 1,137
  • 9
  • 17
Tamati
  • 11
  • 1
  • 7