I have an application which gives me the following error when i run it:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

But the weird thing is, is that sometimes my program runs perfectly without any error, and sometimes it throws that errot to me. Is there anyway i can prevent this from happening?

I have no idea why this error shows up...