Fix for broken pull #4575: Automatic pause/resume when memory dumping - by using a simpler and more safer coding

Fix for broken pull #4575: Automatic pause/resume when memory dumping - by using a simpler and more precautious coding