Fixed an issue when allowed memory size exhausted