There are two reasons for that. First, when the engine is started in debug mode, it allocates more memory for code and variables. When you have a huge script and use large arrays, this can use a lot of memory, up to 100 MB or more.

The second reason is that the engine runs as a SED process in debug mode, meaning that you have to terminate SED after a debug session. Otherwise the memory is not freed and accumulates with every debug run. Of course this does not happen when you only start your project, without debugging.

When you start it from WED with the map open at the same time, you need at least twice the memory. Once for the engine and once for the map in WED. For fixing this, just don't have several programs consuming huge memory amounts running at the same time. Better start the engine with SED, or even better, start it directly with a shortcut or from a command line.