*
* @param appName The name of the app.
* @param appInstance An app instance previous allocated by allocAppInstance.
*/
private static void deallocAppInstance(String appName, int appInstance) {
SmallIntegerAllocator allocator = instanceAllocators.get(appName);
if (allocator == null) {
throw new RuntimeException("Deallocation when app instance is not allocated = " +
appInstance);
}
allocator.free(appInstance);
if (allocator.getNumAllocated() == 0) {
instanceAllocators.remove(appName);
}
}