problem with CPP code compilation in graphics

I am currently writing code using graphics.h header file in Dev-C++ for my college courses. My problem is that on pressing F11, it sometimes compiles and sometimes it fails to compile. Also, sometimes after it gets compiled, I am supposed to get both a CMD screen and a Windows BGI screen. Sometimes one or the other window only pops up. Also I have to input data in the CMD screen but it sometimes fails to show the prompt to input data and instead it stops responding and the screen becomes white. Can someone tell me what is the problem here? The compilation problem never occurs when I don't work with graphics.h header. Is the compilation occurring because of not getting enough RAM or memory space or something?