fix #226 shut down application when allocated resource is not enough and minor bug fix